fetch integer value in XSLT

I have a json input, it has both interger and string values.

{ "name":"jj", "id":123 } 

I’m performing json to json conversion.

using map I’m representing in key and value format.

<string key="name1"> <xsl:value-of select='$data//string[@key="name"]'/> </string> <string key="id1"> <xsl:value-of select='$data//string[@key="id"]'/> </string> 

when i try to fetch integer values its giving indouble quotes.


{ "name1":"jjj", "id1":"" } 

expected output:-

{ "name1":"jj", "id1":123 } 

Thank you…….

Add Comment
1 Answer(s)

JSON only has a single number type, double, represented for xml-to-json or json-to-xml in XSLT 3.0 and XPath 3.1 by the number element, not the string element. Thus use <number key="id1">...</number> on the XML side to end up with a numeric value in JSON.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.