Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing the Freebase Topic HTTP API - JSON & Javascript
    primarykey
    data
    text
    <p>I am trying to parse a JSON output:</p> <p><a href="http://www.freebase.com/experimental/topic/standard?id=/en/colonel_sanders" rel="nofollow noreferrer">http://www.freebase.com/experimental/topic/standard?id=/en/colonel_sanders</a></p> <p>I'd like to put the basic data into an array using Javascript. In the "properties" object I'd like to grab any "text" element one level under "properties" as a label and grab the "text" under the "values" object to match the label.</p> <p>For the above I would get:</p> <ul> <li>"description": "Harland David Sanders, better known as Colonel Sanders...</li> <li>"Organizations founded": KFC </li> <li>"Cause of death": Leukemia</li> <li>"Date of death": Dec 16, 1980</li> <li>"Place of death": Louisville</li> <li>"Date of birth": Sep 9, 1890 </li> <li>"Gender": Male</li> </ul> <p>etc...</p> <p>I have some code which recursively runs through the JSON but I am a novice with javascript and JSON and am having a lot trouble in step one:</p> <p>Firstly, grabbing the "text" trying by identifying an element as being "an element of" the main properties object; then </p> <p>Secondly grabbing from the associated values array any text element (if the value is a collection then I would like to concatenate the strings from the text or otherwise ignore it).</p> <p>I hope that make sense.</p> <p>nb. the code I use is similar to here: <em><a href="http://tlrobinson.net/projects/javascript-fun/jsondiff/" rel="nofollow noreferrer">http://tlrobinson.net/projects/javascript-fun/jsondiff/</a></em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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