in reply to Re^2: Preserve the order in JSON
in thread Preserve the order in JSON

I wrote JSON::MultiValueOrdered to cope with JSON like the following:

{ "foo": 1, "bar": 2, "foo": 3 }

If you parse the above into $data then $data->{foo} will be 3, but tied(%$data)->get('foo') in list context will return ( 1, 3 ), and if you serialize the structure, you'll get this, preserving the original order of the keys:

{ "foo": 1, "bar": 2, "foo": 3 }