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

Function modGroup

gjson.go:3251–3284  ·  view source on GitHub ↗
(json, arg string)

Source from the content-addressed store, hash-verified

3249}
3250
3251func modGroup(json, arg string) string {
3252 res := Parse(json)
3253 if !res.IsObject() {
3254 return ""
3255 }
3256 var all [][]byte
3257 res.ForEach(func(key, value Result) bool {
3258 if !value.IsArray() {
3259 return true
3260 }
3261 var idx int
3262 value.ForEach(func(_, value Result) bool {
3263 if idx == len(all) {
3264 all = append(all, []byte{})
3265 }
3266 all[idx] = append(all[idx], ("," + key.Raw + ":" + value.Raw)...)
3267 idx++
3268 return true
3269 })
3270 return true
3271 })
3272 var data []byte
3273 data = append(data, '[')
3274 for i, item := range all {
3275 if i > 0 {
3276 data = append(data, ',')
3277 }
3278 data = append(data, '{')
3279 data = append(data, item[1:]...)
3280 data = append(data, '}')
3281 }
3282 data = append(data, ']')
3283 return string(data)
3284}
3285
3286// stringHeader instead of reflect.StringHeader
3287type stringHeader struct {

Callers

nothing calls this directly

Calls 4

ParseFunction · 0.85
IsObjectMethod · 0.80
ForEachMethod · 0.80
IsArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…