Implement JSON_PRESERVE_ORDER encoding flag
authorPetri Lehtinen <petri@digip.org>
Tue, 9 Feb 2010 19:29:33 +0000 (21:29 +0200)
committerPetri Lehtinen <petri@digip.org>
Thu, 11 Feb 2010 18:48:56 +0000 (20:48 +0200)
commitf18ef5144a77ebdbe7285711884b217b86e2c3b6
tree1153f7540a5c28fd0a92fbd52044f7e11f69ba4d
parent307167fb66e83946dca6d1b22bc43ae9fd406a16
Implement JSON_PRESERVE_ORDER encoding flag

With this encoding flag, the object key-value pairs in output are in
the same order in which they were first inserted into the object.

To make this possible, a key of an object is now a serial number plus
a string. An object keeps an increasing counter which is used to
assign serial number to the keys. Hashing, comparison and public API
functions were changed to act only on the string part, i.e. the serial
number is ignored everywhere else but in the encoder, where it's used
to order object keys if JSON_PRESERVE_ORDER flag is used.
doc/apiref.rst
src/dump.c
src/jansson.h
src/jansson_private.h
src/value.c
test/bin/json_process.c
test/suites/api/test_object.c
test/suites/encoding-flags/preserve-order/env [new file with mode: 0644]
test/suites/encoding-flags/preserve-order/input [new file with mode: 0644]
test/suites/encoding-flags/preserve-order/output [new file with mode: 0644]