Controlling json serialization of JSON-XML
Friday, 25 May 2018 · 2 messages · last reply 29 May 2018
HE
Hondros, Constantine (ELS-AMS)25 May 2018 17:41 #
Hello all,
I'm expecting the answer to be no, but is it possible to influence the JSON serialization of <number> elements at all?
xml-to-json(
<map xmlns="http://www.w3.org/2005/xpath-functions">
<number key="number">10111234</number>
</map>
)Results in
{"number":1.0111234E7}I read this in the spec, so it looks like the number is always being cast as a double:
xs:string(xs:double(fn:string($E)))TIA,
Constantine
________________________________
Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands.
CG
Christian Grün29 May 2018 10:01 #
Hi Constantine,
The XQuery specifications provide no means to influence the
serialization of numeric values. We could think about adding an additional option for that in our own JSON module.
Cheers,
Christian
Quoted text · Constantine (ELS-AMS) · 24 lines
On Fri, May 25, 2018 at 5:41 PM, Hondros, Constantine (ELS-AMS) <C.Hondros at elsevier.com> wrote: > Hello all, > > I’m expecting the answer to be no, but is it possible to influence the JSON > serialization of <number> elements at all? > > xml-to-json( > <map xmlns="http://www.w3.org/2005/xpath-functions"> > <number key="number">10111234</number> > </map> > ) > > Results in > > {"number":1.0111234E7} > > I read this in the spec, so it looks like the number is always being cast as > a double: > > xs:string(xs:double(fn:string($E))) > > TIA, > Constantine
Written for BaseX 9.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery