MCPcopy Create free account
hub / github.com/blues/note / arrayInterface

Method arrayInterface

jsonxt/decode.go:1040–1063  ·  view source on GitHub ↗

arrayInterface is like array but returns []interface{}.

()

Source from the content-addressed store, hash-verified

1038
1039// arrayInterface is like array but returns []interface{}.
1040func (d *decodeState) arrayInterface() []interface{} {
1041 v := make([]interface{}, 0)
1042 for {
1043 // Look ahead for ] - can only happen on first iteration.
1044 d.scanWhile(scanSkipSpace)
1045 if d.opcode == scanEndArray {
1046 break
1047 }
1048
1049 v = append(v, d.valueInterface())
1050
1051 // Next token must be , or ].
1052 if d.opcode == scanSkipSpace {
1053 d.scanWhile(scanSkipSpace)
1054 }
1055 if d.opcode == scanEndArray {
1056 break
1057 }
1058 if d.opcode != scanArrayValue {
1059 panic(phasePanicMsg)
1060 }
1061 }
1062 return v
1063}
1064
1065// objectInterface is like object but returns map[string]interface{}.
1066func (d *decodeState) objectInterface() map[string]interface{} {

Callers 2

arrayMethod · 0.95
valueInterfaceMethod · 0.95

Calls 2

scanWhileMethod · 0.95
valueInterfaceMethod · 0.95

Tested by

no test coverage detected