From: <Cha...@De...> - 2011-02-15 06:50:17
|
Hello, Is the below patch applied to SVN? Thanks, Sekhar. -----Original Message----- From: P, Chandrasekhar Sent: Monday, January 31, 2011 12:53 PM To: 'jso...@li...' Subject: Patch for Bug ID: 3062498(Bug when parsing duplicate names) Hello Baptiste, Pls review and apply the following patches into SVN as a bug fix: *** jsoncpp-src-0.5.0/include/json/features.h 2010-03-12 13:01:35.000000000 +0530 --- jsoncpp-src-0.5.0-latest/include/json/features.h 2011-01-11 16:08:15.000000000 +0530 *************** *** 23,28 **** --- 23,29 ---- * - Comments are forbidden. * - Root object must be either an array or an object value. * - Assumes Value strings are encoded in UTF-8 + * - Duplicate keys are NOT allowed within objects. */ static Features strictMode(); *************** *** 35,40 **** --- 36,46 ---- /// \c true if root must be either an array or an object value. Default: \c false. bool strictRoot_; + + /** \c true if only unique keys are allowed within objects. Default: \c false. + * - RFC4627 mentions that key name SHOULD be unique + */ + bool uniqueKeys_; }; } // namespace Json *** jsoncpp-src-0.5.0/src/lib_json/json_reader.cpp 2010-03-12 13:01:35.000000000 +0530 --- jsoncpp-src-0.5.0-latest/src/lib_json/json_reader.cpp 2011-01-11 16:50:45.000000000 +0530 *************** *** 19,24 **** --- 19,25 ---- Features::Features() : allowComments_( true ) , strictRoot_( false ) + , uniqueKeys_(false) { } *************** *** 36,41 **** --- 37,43 ---- Features features; features.allowComments_ = false; features.strictRoot_ = true; + features.uniqueKeys_ = true; return features; } *************** *** 505,510 **** --- 507,518 ---- colon, tokenObjectEnd ); } + if(features_.uniqueKeys_ && currentValue().isMember(name)) + { + return addErrorAndRecover( "Duplicate key found", + tokenName, + tokenObjectEnd ); + } Value &value = currentValue()[ name ]; nodes_.push( &value ); bool ok = readValue(); thanks, sekhar. |