authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-27 00:45:46-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-27 00:45:46-05:00
log7818550edcced664344abe1a6a66caea194beccc
treec00a6b47484c11278313b378eb654fd6ca60f685
parent0860be03b154e648a963edf26867b23596ed98f0
parent8d54cbb834ab606ecfe23c6514cbac699319f60c
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'Fix-pushToParent-to-work-for-arrays-of-Objects' of https://github.com/winksaville/zig into winksaville-Fix-pushToParent-to-work-for-arrays-of-Objects


1 files changed, 10 insertions(+), 2 deletions(-)

std/json.zig+10-2
......@@ -1323,7 +1323,8 @@ pub const Parser = struct {
13231323 p.state = State.ObjectKey;
13241324 },
13251325 // Array Parent -> [ ..., <array>, value ]
1326 Value.Array => |*array| {
1326 Value.Array => {
1327 var array = &p.stack.items[p.stack.len - 1].Array;
13271328 try array.append(value);
13281329 p.state = State.ArrayValue;
13291330 },
......@@ -1364,7 +1365,8 @@ test "json.parser.dynamic" {
13641365 \\ "Width": 100
13651366 \\ },
13661367 \\ "Animated" : false,
1367 \\ "IDs": [116, 943, 234, 38793]
1368 \\ "IDs": [116, 943, 234, 38793],
1369 \\ "ArrayOfObject": [{"n": "m"}]
13681370 \\ }
13691371 \\}
13701372 ;
......@@ -1387,4 +1389,10 @@ test "json.parser.dynamic" {
13871389
13881390 const animated = image.Object.get("Animated").?.value;
13891391 debug.assert(animated.Bool == false);
1392
1393 const array_of_object = image.Object.get("ArrayOfObject").?.value;
1394 debug.assert(array_of_object.Array.len == 1);
1395
1396 const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;
1397 debug.assert(mem.eql(u8, obj0.String, "m"));
13901398}