Closed opethe1st closed 5 years ago
func loadSequence(iter *iterator) []interface{} {
seq := make([]interface{}, 0)
consume(iter, '[')
if iter.Current() == ']' {
return seq
}
var item interface{}
for iter.HasNext() {
item = load(iter)
seq = append(seq, item)
consumeWhiteSpace(iter)
if iter.Current() == ']' {
break
} else {
consume(iter, ',')
}
if iter.Current() return nil when offset is bigger than or equal to the length of the string
Figured this out too. iter.Current() can return 0 which is the null character that should never be in a valid string so it works nicely
Also rewrote this so I check the ']' condition at the beginning
https://github.com/opethe1st/GoJson/blob/943435f24b71ab954f52d910ed0931816e51ead5/load.go#L185-L201