Closed baxiry closed 10 months ago
Use the gjson.Parse function which converts a JSON string to a gjson.Result.
obj := `{"a": 1, "b": 2}`
gjson.Parse(obj).ForEach(func(k, v gjson.Result) bool {
// ...
return true
})
Optionally you can use @this
obj := `{"a": 1, "b": 2}`
result := gjson.Get(obj, "@this")
result.ForEach(func(k, v gjson.Result) bool {
// ...
return true
})
Wow! so thanks @tidwall
You're welcome.
I can't use ForEach via json fields. Because it's not gjson.Result type. Currently I use this trick to convert Json string to Resulte type.
I'm looking for a better way to get the same result. any idea ? thank you