[MarkLogic Dev General] JSON transformation problem

Geert Josten Geert.Josten at marklogic.com
Tue Jan 12 05:44:48 PST 2016

Hi Soumadri Roy,

MarkLogic merely omitted non-significant decimals in the serialized form of the JSON, or maybe your browser is actually doing that. The JSON datatype is Number, which is a double by definition, regardless if the number has a fraction or not. See also for instance:


Is this giving you trouble somehow?

Kind regards,

From: <general-bounces at developer.marklogic.com<mailto:general-bounces at developer.marklogic.com>> on behalf of "Roy Chowdhury, Soumadri" <SRRoyChowdhury at INNODATA.COM<mailto:SRRoyChowdhury at INNODATA.COM>>
Reply-To: MarkLogic Developer Discussion <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Date: Tuesday, January 12, 2016 at 1:34 PM
To: "general at developer.marklogic.com<mailto:general at developer.marklogic.com>" <general at developer.marklogic.com<mailto:general at developer.marklogic.com>>
Subject: [MarkLogic Dev General] JSON transformation problem


I am trying to transform the below mentioned XML data into JSON:

When I am executing it against a database which does not have the respective schema associated I am getting the following output:
{"data":{"price1":"10.23", "price2":"10.00"}}

When I am executing it against a database with proper schema associated, it returns the following:
{"data":{"price1":10.23, "price2":10}}

Note that the second one treated the values as integer. This is not happening when the data is returned in XML format.

Why the function is behaving differently in the above two cases and is there a way to retain two decimal places after dot(.) even when the schema is associated?

Soumadri Roy

"This e-mail and any attachments transmitted with it are for the sole use of the intended recipient(s) and may contain confidential , proprietary or privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this e-mail or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20160112/541d6e94/attachment.html 

More information about the General mailing list