xsltjson
xsltjson copied to clipboard
XML2Json convert string to number
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
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')">