Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no way to change jsonObj.MustArray()[i] to *simplejson.Json #92

Open
zhong-wx opened this issue Feb 18, 2021 · 2 comments
Open

no way to change jsonObj.MustArray()[i] to *simplejson.Json #92

zhong-wx opened this issue Feb 18, 2021 · 2 comments

Comments

@zhong-wx
Copy link

I want to iterate an array, and use the elements of the array as *simplejson.Json. I found no function to get size of array, the only way I found is to calculate len(jsonObj.Array), and I have no way to change jsonObj.MustArray()[i] to *simplejson.Json.

@phanirithvij
Copy link

Can you not do this?

arr := jsonObj.MustArray()
for i := 0; i < len(arr); i++ {
        j := &simplejson.Json{data: arr[i]}
       // use j which is *simplejson.Json
}

@ziposcar
Copy link

Can you not do this?

arr := jsonObj.MustArray()
for i := 0; i < len(arr); i++ {
        j := &simplejson.Json{data: arr[i]}
       // use j which is *simplejson.Json
}

The 'data' is private so can not unfortunately.
We true need a method like JSONArray() []*simplejson.Json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants