Closed RezaRahmati closed 4 years ago
This is a little funky, because there are a lot of cases where a key could be overridden... for example, what if the overridden value is already a list?
The "solution" I came up with was to add a config option to build a sort of linked list out of duplicate keys.
parse('{"key": 1, "key": 2, "key": [1, 2, 3]}', {"duplicateKeys": true})
Will give:
{ key: { value: { value: 1, next: 2 }, next: [ 1, 2, 3 ] } }
Hi
I have a string like this
As it's obvious
messages
is duplicate and when I try to use the library it takes the last one, which is good for most cases.I was wondering if it's possible to have an option how to treat duplicates, possible values could be (TakeLast, TakeFirst, ConvertToArray)
For
ConvertToArray
, the output will be something like below