timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

to-json: option to specify sort-comparison block for keys #82

Closed jaguart closed 1 year ago

jaguart commented 2 years ago

to-json: Would be fab if we could specify a sort-comparator for the keys, so that we could control the ordering of the keys in the output.

Given that keys can be multi-level, maybe make $a/$b strings contain the delimited parts of the parent keys - e.g. $a = "one\tgreen\tapple" means that this value is at "one": { "green" : "apple", ... etc. etc. depending on the internals.

This means that I could sort keys according to an arbitrary external priority - like whether an entry in my META6.json is required or optional, or I could even remember incoming JSON key order and write new JSON in the same order with new entries at the end - etc. etc.

coke commented 1 year ago

see #83

timo commented 1 year ago

has been implemented in version 0.19, thanks for the report