top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

detect key conflict in a JSON file

+1 vote
826 views

How can you detect if a key is duplicated in a JSON file? Example:

{
 "something": [...],
 ...
 "something": [...]
}

I have a growing JSON file that I edit manually and it might happen that I repeat a key. If this happens, I would like to get notified. Currently the value of the second key silently overwrites the value of the first.

Do you know about a command line JSON validator?

posted May 29, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
 
Best answer
  1. The real answer here is that JSON is probably not the best choice for large files that get hand-edited. For data that you intend to hand-edit a lot, YAML might be a better choice.

  2. Yeah, that's what I would expect. http://www.json.org/ is mute on the question of what to do with duplicate keys, but I would be quite surprised to discover any implementation which behaved differently.

  3. All JSON implementations validate their input. You are assuming that having duplicate keys is "invalid". I would think it falls more into the category of "undefined behavior".

answer May 29, 2013 by anonymous
0 votes
answer May 29, 2013 by anonymous
Similar Questions
0 votes

Would someone let me know how to verify JSON data in python. There are so many modules available to verify XML file, however I didn't find any good module to verify JSON Data.

After searching on the internet I came across JSON module, however it only coverts the JSON data to python. it's good, however the problem comes when JSON response is very large.

Is there any module through which I can verify JSON file like DOM or Object oriented way. ( i.e. data.key)

+2 votes

I have a requirement in which I will get data in CSV file. I have to create a JSON file for this data. Please suggest me how I can implement this in Informatica Power Centre.

...