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

XML2Json convert string to number #17

Open
suhakopan opened this issue Jan 24, 2020 · 1 comment
Open

XML2Json convert string to number #17

suhakopan opened this issue Jan 24, 2020 · 1 comment

Comments

@suhakopan
Copy link

suhakopan commented Jan 24, 2020

Hi everyone,

I am using xml2json transform file.

My xml element:

<id>9999</id>

But after transform xml2json:

"id": 9999,

I want to this;

"id": "9999"

Because target source waiting to me this field string,but this file convert auto number my fields.

Please help

@ranania
Copy link

ranania commented Jan 27, 2021

There is a condition near the end of the file that determines what should be treated as a string. Just modify the line below.

<xsl:when test="normalize-space(.) ne . or not((string(.) castable as xs:integer and not(starts-with(string(.),'+')) and not(starts-with(string(.),'0') and not(. = '0'))) or (string(.) castable as xs:decimal and not(starts-with(string(.),'+')) and not(starts-with(.,'-.')) and not(starts-with(.,'.')) and not(starts-with(.,'-0') and not(starts-with(.,'-0.'))) and not(ends-with(.,'.')) and not(starts-with(.,'0') and not(starts-with(.,'0.'))) )) and not(. = 'false') and not(. = 'true') and not(. = 'null')">

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