-
Notifications
You must be signed in to change notification settings - Fork 1
/
iter_array.go
36 lines (34 loc) · 807 Bytes
/
iter_array.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package jsoniter
// ReadArrayHead tells if there is array element to read, if the value is not array will be skipped
func (iter *Iterator) ReadArrayHead() bool {
c := iter.nextToken()
if c != '[' {
if c == 'n' {
iter.skipThreeBytes('u', 'l', 'l') // null
return false
}
iter.ReportError("ReadArrayHead", "expect [, but found "+string([]byte{c}))
iter.skip(c)
return false
}
c = iter.nextToken()
if c == ']' {
// [] is empty array
return false
}
iter.unreadByte()
return true
}
// ReadArrayMore tells if there is more element to read
func (iter *Iterator) ReadArrayMore() bool {
c := iter.nextToken()
switch c {
case ',':
return true
case ']':
return false
default:
iter.ReportError("ReadArrayMore", "expect , or ], but found "+string([]byte{c}))
return false
}
}