Skip to content

Reject dup keys #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 6, 2015
Merged

Reject dup keys #205

merged 3 commits into from
Mar 6, 2015

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.

1 participant