I have been working a bit with the new serialise and deserialize commands and JSON containing various types of numbers, and the results are wildly inconsistent.
An example JSON containing various types of numbers, and numbers as strings:
Code: Select all
{
"1": "7",
"2": 7,
"3": "7.1",
"4": 7.1,
"5": 7.14,
"6": "7.14",
"8": "7.1234567"
}
Code: Select all
global a "{\"1\":\"7\",\"2\":7,\"3\":\"7.1\",\"4\":7.1,\"5\":7.14,\"6\":\"7.14\",\"8\":\"7.1234567\"}"
global b [deserialize $a from=json ]
put $b
1=7;2=7;3=7.0.0.1;4=7.1;5=7.14;6=7.0.0.14;8=00:00:07.123456700
global c [serialize $b to=json ]
put $c
{"1":7,"2":7,"3":"7.0.0.1","4":7.100000,"5":7.140000,"6":"7.0.0.14","8":"1970-01-01 00:00:07"}
Code: Select all
{
"1": 7,
"2": 7,
"3": "7.0.0.1",
"4": 7.1,
"5": 7.14,
"6": "7.0.0.14",
"8": "1970-01-01 00:00:07"
}
Code: Select all
global d
set ($d->"1") "7"
set ($d->"2") 7
global e [serialize $d to=json ]
put $d
1=7;2=7
put $e
{"1":7.000000,"2":7}
I have created a support ticket on this also: SUP-138863