简体   繁体   English

从JSON.parse访问值

[英]Access Value from JSON.parse

I'm having issues accessing values from json using json.parse. 我在使用json.parse从json访问值时遇到问题。 This is my JSON: 这是我的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. 我正在尝试从store阵列中获取name

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? 如何获得该值?

This should work. 这应该工作。

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

or 要么

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

尝试console.log(cif[0].store[0].name)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM