Help with parsing json

sdk

#1

When i call an api that returns a random quote in son format (a title and content), i receive the json just fine :

ajax({ url: ‘quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1’, type: ‘json’ },
function(data) {
console.log(( JSON.stringify( data ) ));
console.log(data.content);

console.log(( JSON.stringify( data ) )); outputs : [{“ID”:1562,“title”:“Michael Bierut”,“content”:“Most of the mediocre design today comes from designers who are faithfully doing as they were taught in school: they worship at the altar of the visual.
”,“link”:“http://quotesondesign.com/michael-bierut-3/",“custom_meta”:{“Source”:"article”}}]

But console.log(data.content); outputs : none.

I don’t get it and im starting to pull my hair out, please help.


#2

had to take out the http part because i cant post links yet


#3

The response json is wrapped in an array, with just one object. Try this:

console.log(data[0].content);


#4

Try this: json formatter https://jsonformatter-online.com


#5

Try https://jsonformatter.org to validate and format JSON data.