A
A
Alexander2015-09-29 12:50:28
JSON
Alexander, 2015-09-29 12:50:28

How to get all duplicated keys from JSON file?

There is a JSON file with no attachment, i.e. the value of each key is not an object. There are duplicate keys in this file, which JS in the form of JSON.parse ignores, but this leads to problems. I would like to find all duplicate pairs of values. How can I do that? Desirable implementation on node.js. Maybe there is an already written json linter that can do what is described above, I just could not find it.
Example:

{
    "x": 4,
    "x": 5
}

In this case, you need to deduce that the key "x" is repeated

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sasha, 2015-09-29
@madmages

this is not a valid json, so all the parsers just think for you and do "good". in fact, if you want your own logic, you will need to write your own json parser. Good luck with this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question