sile / jsone

Erlang JSON library
MIT License
291 stars 71 forks source link

Add option to return last duplicate property #48

Closed russelldb closed 4 years ago

russelldb commented 4 years ago

RFC4627 says "The names within an object SHOULD be unique." Not MUST. Most JSON parsers pick either the first duplicate instance, or the last. I'm working between Rust and Erlang (via rustler) and wanted the option to match serde_json's approach of picking the last duplicate key in an object.

This change adds a new option duplicate_map_keys with the allowed values first and last. first matches the current behaviour, and is the default.