1

I'm having issues accessing values from json using json.parse. This is my JSON:

  [  
   {  
      "store":[  
         {  
            "name":"Grand Theft Auto V"
         },
         {  
            "skuid":"UP1004-CUSA00419_00-GTAVDIGITALDOWNL-U001"
         },
         {  
            "releasedate":"2014-11-18T00:00:00Z"
         }         //...

I'm trying to get the name from the store array.

var cif = JSON.parse(response);

// Tried the following:
alert(cif["store"][0].name);
alert(cif.store[0].name);
alert(cif[0].store.name);
alert(cif["store"].name);

if(cif.store[0].name) $("#cif-title").html(cif.store[0].name);

How do I access this value?

0

2 Answers 2

3

This should work.

alert(cif[0]["store"][0]["name"]);

or

alert(cif[0].store[0].name);
Sign up to request clarification or add additional context in comments.

1 Comment

That indeed works, but other values like skuid return undefined with this method, is there a fix for that?
1

Try console.log(cif[0].store[0].name)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.