MCPcopy
hub / github.com/tidwall/gjson / Array

Method Array

gjson.go:202–211  ·  view source on GitHub ↗

Array returns back an array of values. If the result represents a null value or is non-existent, then an empty array will be returned. If the result is not a JSON array, the return value will be an array containing one result.

()

Source from the content-addressed store, hash-verified

200// If the result is not a JSON array, the return value will be an
201// array containing one result.
202func (t Result) Array() []Result {
203 if t.Type == Null {
204 return []Result{}
205 }
206 if !t.IsArray() {
207 return []Result{t}
208 }
209 r := t.arrayOrMap('[', false)
210 return r.a
211}
212
213// IsObject returns true if the result value is a JSON object.
214func (t Result) IsObject() bool {

Callers 8

TestBasic3Function · 0.95
TestBasic2Function · 0.80
TestIssue6Function · 0.80
TestSingleArrayValueFunction · 0.80
TestNullArrayFunction · 0.80
TestArrayValuesFunction · 0.80
TestIssue240Function · 0.80
TestQueryGetPathFunction · 0.80

Calls 2

IsArrayMethod · 0.95
arrayOrMapMethod · 0.95

Tested by 8

TestBasic3Function · 0.76
TestBasic2Function · 0.64
TestIssue6Function · 0.64
TestSingleArrayValueFunction · 0.64
TestNullArrayFunction · 0.64
TestArrayValuesFunction · 0.64
TestIssue240Function · 0.64
TestQueryGetPathFunction · 0.64