xml-js icon indicating copy to clipboard operation
xml-js copied to clipboard

Empty String of nativeTypeAttributes converted zero

Open cagriman opened this issue 2 years ago • 3 comments

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 avatar Feb 16 '23 14:02 cagriman

Hello,

I solved my problem with adding below option to options.

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

Issue can be close.

Thanks

cagriman avatar Mar 16 '23 08:03 cagriman

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 avatar Mar 20 '23 07:03 cagriman

I am having the same issue.

Jzeemo avatar Mar 20 '24 10:03 Jzeemo