After some recent announcement of ordered maps in the BaseX fiddle I played around with some JSON serialization, to my surprise the result is different whether I use the serialize function directly on a single map https://fiddle.basex.org/?share=%28%27query%21%27%2803.*2%2C%5Cn%28.30*24%21%27%27%7Emode%21%27XQuer7%7BBaseX%7D4Type%21%27xml%27%29*%29+%3D%3E+serializ9%28%22method6json%223%22indent-tru6+%3A+.%22data-arra7%28+1+to+580%22foo6bar%2229%7D8%7D3%2C+4%27%7Econtext6-%227y+8+%299e%7B%0198764320.-*_:
{'foo' : 'bar', 'data' : array { 1 to 5 }} => serialize({'method' : 'json', 'indent' : true() }), {'data' : array { 1 to 5 }, 'foo' : 'bar'} => serialize({'method' : 'json', 'indent' : true() })
gives
{ "foo": "bar", "data": [ 1, 2, 3, 4, 5 ] } { "data": [ 1, 2, 3, 4, 5 ], "foo": "bar" }
for $map in ({'foo' : 'bar', 'data' : array { 1 to 5 }}, {'data' : array { 1 to 5 }, 'foo' : 'bar'}) return serialize($map, {'method' : 'json', 'indent' : true() })
gives
{ "foo": "bar", "data": [ 1, 2, 3, 4, 5 ] } { "foo": "bar", "data": [ 1, 2, 3, 4, 5 ] }
Should the JSON serialization reflect the map as created or is that still random/arbitrary order for the properties?