File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed
Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 66
77* Added support for custom writer classes (issue #1088 )
88* Added conversion from ` JsonArray ` and ` JsonObject ` to ` bool ` , to be consistent with ` JsonVariant `
9+ * Fixed ` deserializeJson() ` when input contains duplicate keys (issue #1095 )
910
1011v6.12.0 (2019-09-05)
1112-------
Original file line number Diff line number Diff line change @@ -277,6 +277,7 @@ TEST_CASE("deserialize JSON object") {
277277 DeserializationError err = deserializeJson (doc, " {a:{b:{c:1}},a:2}" );
278278
279279 REQUIRE (err == DeserializationError::Ok);
280+ REQUIRE (doc[" a" ] == 2 );
280281 }
281282 }
282283
Original file line number Diff line number Diff line change @@ -130,15 +130,21 @@ class JsonDeserializer {
130130
131131 // Read each key value pair
132132 for (;;) {
133- // Allocate slot in object
134- VariantSlot *slot = object.addSlot (_pool);
135- if (!slot) return DeserializationError::NoMemory;
136-
137133 // Parse key
138134 const char *key;
139135 err = parseKey (key);
140136 if (err) return err;
141- slot->setOwnedKey (make_not_null (key));
137+
138+ VariantData *variant = object.get (adaptString (key));
139+ if (!variant) {
140+ // Allocate slot in object
141+ VariantSlot *slot = object.addSlot (_pool);
142+ if (!slot) return DeserializationError::NoMemory;
143+
144+ slot->setOwnedKey (make_not_null (key));
145+
146+ variant = slot->data ();
147+ }
142148
143149 // Skip spaces
144150 err = skipSpacesAndComments ();
@@ -147,7 +153,7 @@ class JsonDeserializer {
147153
148154 // Parse value
149155 _nestingLimit--;
150- err = parseVariant (*slot-> data () );
156+ err = parseVariant (*variant );
151157 _nestingLimit++;
152158 if (err) return err;
153159
You can’t perform that action at this time.
0 commit comments