Hi Martin,
Thanks for the observation. It was the query optimizer that rewrote (map1, map2) to replicate(map1, 2). The order is now taken into consideration, and the two maps are treated as different items.
Note that, for backward compatibility, we can expect fn:deep-equal($map1, $map2) to continue to return true, even if maps have a different order.
Best, Christian
On Sun, Dec 29, 2024 at 5:44 PM Martin Honnen martin.honnen@gmx.de wrote:
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?