0

Can you help me to parse a JSON file in a array so that I can iterate over it and display the contents on my lightning component?

Getting the JSON response from here: https://api.airbnb.com/v2/search_results?client_id=3092nxybyb0otqw18e8nh5nty&location=dublin

Now I need to show the listings object as a list on the component using aura:iteration attribute.

Any help?

3

2 Answers 2

4

If you mean on the client side, then its just:

var json = ...;

var parsed = JSON.parse(json);
var results = parsed.search_results;
component.set("v.listings", results);
0

I guess before parse once go stringify then parse like.

var obj;
var jsonString = JSON.parse(JSON.stringify(obj));
// Now you getting the parse format json.
component.set('v.returnData', jsonString);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .