aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json.zig
diff options
context:
space:
mode:
authorxackus <14938807+xackus@users.noreply.github.com>2020-04-02 00:00:42 +0200
committerxackus <14938807+xackus@users.noreply.github.com>2020-04-02 16:12:08 +0200
commit7a28c644aa8eb3d27dee113338af8278f8f6334f (patch)
treede1a483b9d9fa9224a50c94522da6bb3308b016c /lib/std/json.zig
parentd3ab0eb28de5a5a94fd4ef988dd4c4b0e3ddf927 (diff)
downloadzig-7a28c644aa8eb3d27dee113338af8278f8f6334f.tar.gz
zig-7a28c644aa8eb3d27dee113338af8278f8f6334f.zip
new ArrayList API: fix everything else
Diffstat (limited to 'lib/std/json.zig')
-rw-r--r--lib/std/json.zig20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/std/json.zig b/lib/std/json.zig
index 12020e6e25..79830d8a2c 100644
--- a/lib/std/json.zig
+++ b/lib/std/json.zig
@@ -1556,7 +1556,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options:
else => {},
}
- try arraylist.ensureCapacity(arraylist.len + 1);
+ try arraylist.ensureCapacity(arraylist.items.len + 1);
const v = try parseInternal(ptrInfo.child, tok, tokens, options);
arraylist.appendAssumeCapacity(v);
}
@@ -1874,7 +1874,7 @@ pub const Parser = struct {
try p.transition(&arena.allocator, input, s.i - 1, token);
}
- debug.assert(p.stack.len == 1);
+ debug.assert(p.stack.items.len == 1);
return ValueTree{
.arena = arena,
@@ -1888,7 +1888,7 @@ pub const Parser = struct {
switch (p.state) {
.ObjectKey => switch (token) {
.ObjectEnd => {
- if (p.stack.len == 1) {
+ if (p.stack.items.len == 1) {
return;
}
@@ -1907,8 +1907,8 @@ pub const Parser = struct {
},
},
.ObjectValue => {
- var object = &p.stack.items[p.stack.len - 2].Object;
- var key = p.stack.items[p.stack.len - 1].String;
+ var object = &p.stack.items[p.stack.items.len - 2].Object;
+ var key = p.stack.items[p.stack.items.len - 1].String;
switch (token) {
.ObjectBegin => {
@@ -1950,11 +1950,11 @@ pub const Parser = struct {
}
},
.ArrayValue => {
- var array = &p.stack.items[p.stack.len - 1].Array;
+ var array = &p.stack.items[p.stack.items.len - 1].Array;
switch (token) {
.ArrayEnd => {
- if (p.stack.len == 1) {
+ if (p.stack.items.len == 1) {
return;
}
@@ -2021,12 +2021,12 @@ pub const Parser = struct {
}
fn pushToParent(p: *Parser, value: *const Value) !void {
- switch (p.stack.span()[p.stack.len - 1]) {
+ switch (p.stack.span()[p.stack.items.len - 1]) {
// Object Parent -> [ ..., object, <key>, value ]
Value.String => |key| {
_ = p.stack.pop();
- var object = &p.stack.items[p.stack.len - 1].Object;
+ var object = &p.stack.items[p.stack.items.len - 1].Object;
_ = try object.put(key, value.*);
p.state = .ObjectKey;
},
@@ -2165,7 +2165,7 @@ test "json.parser.dynamic" {
testing.expect(animated.Bool == false);
const array_of_object = image.Object.get("ArrayOfObject").?.value;
- testing.expect(array_of_object.Array.len == 1);
+ testing.expect(array_of_object.Array.items.len == 1);
const obj0 = array_of_object.Array.at(0).Object.get("n").?.value;
testing.expect(mem.eql(u8, obj0.String, "m"));