Print JSON object with jQuery

jquery, json

Solution

You are iterating the `data.result`, I believe you need to iterate the `Extras`.

$.each(data.result.Extras, function(k, v){
  $("#result").append('<li>'+v+'</li>');
});

Note: In the above function `k` is key and `v` is value in the object `Extras`. For ex: For the first iterate `k` would be `T01` and `v` would be `Value 1`.

The above should produce and output of

<ul id="result">
   <li>Value 1</li>
   <li>Value 2</li>
   <li>Value 3</li>
</ul>

Problem

I have some JSON data looking like this: ``` "Extras": { "T01": "Value 1", "T02": "Value 2", "T03": "Value 3", // etc. } ``` I need each of these values in a list, and so I've tried this: ``` $.each(data.result, function(i){ $("#result").append('<li>'+data.result.Extras[]+'</li>'); }); ``` Which obviously doesn't work, I just can't seem to figure out what to do. I've tried `data.result.Extras` with no luck (as I just get `[object][Object]`). Any ideas what I can do to get all of the values in a list? Thanks!

Original source