Some simple JSON help please!

I’m a bit rusty on JSON stuff, and am having a bit of a brainfart with something.

I need to get some data on a page from a feed which doesn’t look quite like I’m used to seeing with JSON. It looks like something that the provider has repurposed from something they’ve done for others in the past. Ideally I’d get them to change the feed but deadlines and language barriers prevent this.

This is the construction I have (what is provided in the JavaScript file that we need to pull in):


So, presumably, I need to write a function with matching name that accepts what’s passed in above, so:

function parseInfo(jsonStuff) {

But I can’t seem to work out the JS I need to loop through what’s been passed in.

It’s probably MEGA simple, but I can’t get my usual approaches to work.

Could someone kindly provide a snippet of code that will iterate through that data in the structure that I’ve given above? Would really appreciate it :slight_smile:


Hi there,

As far as I know, this:


will always throw an error.

This is because the curly braces denote an object literal, which is a list of zero or more pairs of property names and associated values, separated with a semi-colon, not a comma.

If you can change the above, this will work:

 "item1": "val1",
 "item1": "val2",
 "item1": "val3"

as will this:

 "item1", "val1",
 "item1", "val2",
 "item1", "val3"

However, from my understanding of your question, this may not be possible.

Does that help any?

Thanks - I actually typed it wrong in my original post (it should have had the colon rather than the comma). However, managed to work out what I was doing wrong and all sorted now :slight_smile:

That’s good :slight_smile:

Would you mind sharing your solution, as there are a number of ways to do this and it could help someone with the same problem in the future.