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 {...@@ -1323,7 +1323,8 @@ pub const Parser = struct {
1323 p.state = State.ObjectKey;1323 p.state = State.ObjectKey;
1324 },1324 },
1325 // Array Parent -> [ ..., <array>, value ]1325 // Array Parent -> [ ..., <array>, value ]
1326 Value.Array => |*array| {1326 Value.Array => {
1327 var array = &p.stack.items[p.stack.len - 1].Array;
1327 try array.append(value);1328 try array.append(value);
1328 p.state = State.ArrayValue;1329 p.state = State.ArrayValue;
1329 },1330 },
...@@ -1364,7 +1365,8 @@ test "json.parser.dynamic" {...@@ -1364,7 +1365,8 @@ test "json.parser.dynamic" {
1364 \\ "Width": 1001365 \\ "Width": 100
1365 \\ },1366 \\ },
1366 \\ "Animated" : false,1367 \\ "Animated" : false,
1367 \\ "IDs": [116, 943, 234, 38793]1368 \\ "IDs": [116, 943, 234, 38793],
1369 \\ "ArrayOfObject": [{"n": "m"}]
1368 \\ }1370 \\ }
1369 \\}1371 \\}
1370 ;1372 ;
...@@ -1387,4 +1389,10 @@ test "json.parser.dynamic" {...@@ -1387,4 +1389,10 @@ test "json.parser.dynamic" {
13871389
1388 const animated = image.Object.get("Animated").?.value;1390 const animated = image.Object.get("Animated").?.value;
1389 debug.assert(animated.Bool == false);1391 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"));
1390}1398}