question about nested nested nested JSON
Closed this issue · 0 comments
gmolveau commented
Hello ! First, thank you for your work :)
I do have a question concerning how to use gabs for nested JSON and I'd like your help.
I have this complicated JSON (from Tumblr API) link_to_json
And I'd like for each post in response.posts, to get the ["tags"] and to get the url from "original_size" from photos.
I actually began to write :
posts_parsed, err := gabs.ParseJSON( getContents(posts_json_url) )
if err != nil {
log.Fatal("Error parsing blog JSON !")
return "json success=false, error="
}
posts, _ := jsonParsed.S("response.posts").Children()
for _, post_ar := range posts {
post, _ := jsonParsed.S(post_ar).ChildrenMap()
if post["type"] != "photo" {
continue
}
for _,tag_name := range post["tags"] {
tags := strings.Split(tag_name, " ")
for _,tag_title := range tags {
............
but I don't know if it's correct.
Would it be possible for you to add a complex JSON iteration in your doc ?
Thank you for your help :D