That is by design since ordered state isn't serializable. One option would be to always use ordered (treemap) implementation in the decoder. It would be a bit slower, but might give more robust results which always match the text deserialized. I'd like to hear some feedback and support for that change before making it though
endragorThu 15 Nov 2012
Why not add it as a deserialization option?
jodastephenFri 16 Nov 2012
The test case just looks like a bug to me. "ordered" is a key part of the state and should be serialised.
bedlaMon 28 Jan 2013
I agree with jodastephen :)
SlimerDudeWed 18 Jun 2014
I've just been bit by this.
I was storing some data in a WebSession and was expecting my data to be regurgitated in the same state as it went in. As it stands my map data comes back in a different order than it went in.
You wouldn't expect the values of a list to come back all jumbled up! The same goes for an ordered map.
Could ordered and caseInsensitive be serialised with the map, and be read back first before the data?
brianWed 18 Jun 2014
Promoted to ticket #2059 and assigned to brian
I think what I finally decided in JSON was to always deserialize maps in order. Its a bit slower, but simplest solution for "just works"
brianThu 8 Jan 2015
Ticket resolved in 1.0.67
Change fantom deserialization to always use ordered maps to match the behavior in JSON. This doesn't actually maintain the ordered/case insensitive state - that would require redesigning the serialize syntax itself.
SlimerDudeThu 8 Jan 2015
Cool, I saw the LinkedHashMap change!
This doesn't actually maintain the ordered/case insensitive state
Fair enough, could a sentence to this effect be added to the docs, so it doesn't catch people out?
SlimerDudeFri 12 Jan 2018
I noted that the Fantom JS implementation doesn't have this change, which can (or did!) trip you up when passing data from a (Java) server to a (JS) browser.
I think this (untested) patch may be all that's needed:
endragor Thu 15 Nov 2012
prints
brian Thu 15 Nov 2012
That is by design since ordered state isn't serializable. One option would be to always use ordered (treemap) implementation in the decoder. It would be a bit slower, but might give more robust results which always match the text deserialized. I'd like to hear some feedback and support for that change before making it though
endragor Thu 15 Nov 2012
Why not add it as a deserialization option?
jodastephen Fri 16 Nov 2012
The test case just looks like a bug to me. "ordered" is a key part of the state and should be serialised.
bedla Mon 28 Jan 2013
I agree with jodastephen :)
SlimerDude Wed 18 Jun 2014
I've just been bit by this.
I was storing some data in a
WebSession
and was expecting my data to be regurgitated in the same state as it went in. As it stands my map data comes back in a different order than it went in.You wouldn't expect the values of a list to come back all jumbled up! The same goes for an ordered map.
Could
ordered
andcaseInsensitive
be serialised with the map, and be read back first before the data?brian Wed 18 Jun 2014
Promoted to ticket #2059 and assigned to brian
I think what I finally decided in JSON was to always deserialize maps in order. Its a bit slower, but simplest solution for "just works"
brian Thu 8 Jan 2015
Ticket resolved in 1.0.67
Change fantom deserialization to always use ordered maps to match the behavior in JSON. This doesn't actually maintain the ordered/case insensitive state - that would require redesigning the serialize syntax itself.
SlimerDude Thu 8 Jan 2015
Cool, I saw the
LinkedHashMap
change!Fair enough, could a sentence to this effect be added to the docs, so it doesn't catch people out?
SlimerDude Fri 12 Jan 2018
I noted that the Fantom JS implementation doesn't have this change, which can (or did!) trip you up when passing data from a (Java) server to a (JS) browser.
I think this (untested) patch may be all that's needed:
andy Fri 12 Jan 2018
Is there a test in test suite somewhere we can check against?
SlimerDude Fri 12 Jan 2018
I found this in
/testSys/fan/TestSerialization.fan
:If it happens to pass, my issue used
Uri
as the key.andy Fri 12 Jan 2018
Thanks Steve -- I'm going to split this out into a sep ticket