Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty String of nativeTypeAttributes converted zero #198

Open
cagriman opened this issue Feb 16, 2023 · 3 comments
Open

Empty String of nativeTypeAttributes converted zero #198

cagriman opened this issue Feb 16, 2023 · 3 comments

Comments

@cagriman
Copy link

Hello,

With nativeTypeAttributes = true configuration transformation of json to xml, getting some invalid result as explained that xml attribute valued as Empty String converted to Zero as Number.

Could you fix it ?

Thanks

@cagriman
Copy link
Author

cagriman commented Mar 16, 2023

Hello,

I solved my problem with adding below option to options.

attributeValueFn: (val: any) => (val === 0) ? '' : val

Issue can be close.

Thanks

@cagriman
Copy link
Author

Hello,

But this function replace all zeros to string empty :) I mean this method runs after conversion not before :(

Sample XML ====>
Result JSON =====> { "test:": { "_attributes" : { "att1": 0, "att2": 0 } } }
Expected JSON ===> { "test:": { "_attributes" : { "att1": "", "att2": 0 } } }

@cagriman cagriman reopened this Mar 20, 2023
@Jzeemo
Copy link

Jzeemo commented Mar 20, 2024

I am having the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants