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

Function modValues

gjson.go:3128–3149  ·  view source on GitHub ↗

@values extracts the values from an object. {"first":"Tom","last":"Smith"} -> ["Tom","Smith"]

(json, arg string)

Source from the content-addressed store, hash-verified

3126//
3127// {"first":"Tom","last":"Smith"} -> ["Tom","Smith"]
3128func modValues(json, arg string) string {
3129 v := Parse(json)
3130 if !v.Exists() {
3131 return "[]"
3132 }
3133 if v.IsArray() {
3134 return json
3135 }
3136 var out strings.Builder
3137 out.WriteByte('[')
3138 var i int
3139 v.ForEach(func(_, value Result) bool {
3140 if i > 0 {
3141 out.WriteByte(',')
3142 }
3143 out.WriteString(value.Raw)
3144 i++
3145 return true
3146 })
3147 out.WriteByte(']')
3148 return out.String()
3149}
3150
3151// @join multiple objects into a single object.
3152//

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
ExistsMethod · 0.80
IsArrayMethod · 0.80
ForEachMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…