Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cdunn2001
Copy link
Contributor

https://sourceforge.net/p/jsoncpp/bugs/22/

Sekhar (shakers007) wrote:

As per RFC4627 (section 2.2), names within an object should be unique. When using JSONCPP's strict mode, parsing such an object should fail.
As of now, JSONCPP does not return an error:

Sample JSON (duplicate_key.json):

{
  "Object": {
    "Key":"Value",
    "Key":"Value"}
}

Sample code to test the above file:

ifstream inFile("duplicate_key.json");
Json::Value root;
Json::Reader reader(Json::Features::strictMode());
if ( false==reader.parse( inFile, root, false ) )
{
  cerr << "Error reading file " << reader.getFormatedErrorMessages() << endl;
}
cout << root["Object"] << endl;

Output:

{
  "Key" : "Value"
}

cdunn2001 added a commit that referenced this pull request Mar 6, 2015
[Shekhar (shakers007) wrote](https://sourceforge.net/p/jsoncpp/bugs/22/):

> As per RFC4627 (section 2.2), names within an object should be unique. When using JSONCPP's strict mode, parsing such an object should fail.
@cdunn2001 cdunn2001 merged commit b2a7438 into master Mar 6, 2015
@cdunn2001 cdunn2001 deleted the reject-dup-keys branch March 6, 2015 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants