From:
Thompson, Timothy <timothy.thompson@yale.edu>
Date: Sunday, December 10, 2023 at 1:22 PM
To: BaseX <basex-talk@mailman.uni-konstanz.de>
Subject: JSON number serialization
Hello,
Is it part of the spec that numbers in the “basic” JSON representation (of 7+ digits) be serialized using scientific notation? For example:
let $direct := <json type="object"><n type="number">1339029</n></json>
let $basic := <fn:map><fn:number key="n">1339029</fn:number></fn:map>
let $result := ($direct, $basic) ! serialize(., map {
"method": "json", "json": map {
"format": if (position() eq 1) {"direct"} else {"basic"}, "indent": "yes"
}
})
return $result
…produces two different results:
{
"n":1339029
}
{
"n":1.339029E6
}
I usually prefer working with the “basic” format, but the automatic conversion to scientific notation is inconvenient because the value is not easily castable as an xs:integer.
Thanks in advance,
Tim