Note that there are some explanatory texts on larger screens.

plurals
  1. POLooping through multilayer json Jquery
    text
    copied!<p>Hi i'm quite new to jquery and json so please bear with me. I have searched the forums and tried a lot of different things to solve my problem.</p> <p>I'm trying to loop through a multilayer JSON file form Freebase.</p> <pre><code>$.getJSON(service_url + topic_id + '?callback=?', params, function(topic) { $("#free").append('&lt;h3&gt;Description&lt;/h3&gt;&lt;p&gt;'+topic.property['/common/topic/description'].values[0].value+'&lt;/p&gt;'); $("#title").prepend('&lt;h2&gt;'+topic.property['/type/object/name'].values[0].value+'&lt;span&gt;&lt;a class="socila-link" style="color:#3b5998;" href="'+topic.property['/common/topic/social_media_presence'].values[0].value+'"&gt; &lt;i class="icon-facebook-sign"&gt;&lt;/i&gt;&lt;/a&gt;&lt;a class="socila-link" style="color:#0084B4" href="'+topic.property['/common/topic/social_media_presence'].values[2].value+'"&gt; &lt;i class="icon-twitter-sign"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;') $("#fb-span1").append('&lt;p&gt;&lt;strong&gt;Official Website: &lt;/strong&gt;&lt;a href="'+topic.property['/common/topic/official_website'].values[0].value+'"&gt;'+topic.property['/common/topic/official_website'].values[0].value+'&lt;/a&gt;&lt;/p&gt;'); $("#fb-span1").append('&lt;p&gt;&lt;strong&gt;Genre: &lt;/strong&gt;'+topic.property['/music/artist/genre'].values[0].text+'&lt;/p&gt;'); $("#fb-span1").append('&lt;p&gt;&lt;strong&gt;Founded: &lt;/strong&gt;'+topic.property['/music/artist/active_start'].values[0].text+'&lt;/p&gt;'); $("#fb-span1").append('&lt;p&gt;&lt;strong&gt;Hometown: &lt;/strong&gt;'+topic.property['/music/artist/origin'].values[0].text+'&lt;/p&gt;'); $.each(topic.property, function(i, val) { $("#fb-span1").append('&lt;p&gt;&lt;strong&gt;Genre: &lt;/strong&gt;'+val['/music/artist/genre'].values['text']+'&lt;/p&gt;'); }); </code></pre> <p>I have no problems getting the result if i enter the value like [0], but i cant seem to loop through it.Nothing gets returnet</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload