javascript - 从 Node.js 中的 GetALexDataInJSONResult JSON 数组读取值

标签 javascript arrays node.js

从 Node.js 中的 JSON 数组读取值

我的回应

   {
    "GetALexDataInJSONResult": [
        {
            "projectid": 6,
            "FullName": "Four laning of Deoli- Kota Section of NH-12 from Km 165.000 to Junction of NH-76 on  Kota Bypass in the State of Rajasthan on BOT (Toll) project on DBFOT pattern under NHDP Phase-III.",
            "piu": "PIU Kota",
            "NumberofLanes": "4L",
            "NHNo_New": "52",
            "NHNo_Old": "12",
            "Total_Length": 83.04,
            "state_name": "Rajasthan"
        }
}

我需要从以下数组访问“FullName”值 -

错误

 throw err;
    ^

TypeError: Cannot read property '0' of undefined
    at FullNameIntent.customNode (C:\Users\SKBHATI\Desktop\CodeAlexaProject\AlexaNHAIProject\lambda\custom\index.js:64:60)
    at IncomingMessage.res.on (C:\Users\SKBHATI\Desktop\CodeAlexaProject\AlexaNHAIProject\lambda\custom\index.js:137:11)
    at IncomingMessage.emit (events.js:165:20)
    at endReadableNT (_stream_readable.js:1101:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

最佳答案

var obj =    {
    "GetALexDataInJSONResult": [
        {
            "projectid": 6,
            "FullName": "Four laning of Deoli- Kota Section of NH-12 from Km 165.000 to Junction of NH-76 on  Kota Bypass in the State of Rajasthan on BOT (Toll) project on DBFOT pattern under NHDP Phase-III.",
            "piu": "PIU Kota",
            "NumberofLanes": "4L",
            "NHNo_New": "52",
            "NHNo_Old": "12",
            "Total_Length": 83.04,
            "state_name": "Rajasthan"
        }
     ]
}

var myObj = JSON.parse(obj);
var fullName = myObj["GetALexDataInJSONResult"][0]["FullName"]

关于javascript - 从 Node.js 中的 GetALexDataInJSONResult JSON 数组读取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48985327/

相关文章:

javascript - 德鲁巴 : Flowplayer API not loaded

arrays - MATLAB 查找字符串,存储在数组中并连接

javascript - 找不到模块 './App.svelte' 或其对应的类型声明

ios - 尝试添加 ios 平台项目时出现 Ionic Framework 错误

javascript - Jquery 并将事件绑定(bind)到 iframe

Javascript从两个对象数组生成矩阵

javascript - 动态更改 MongoDB ReplicaSet 中的 Node

ios - 我可以在一个阵列中存储多个NSMutableArray?

c - 总线错误 :10 when try to reverse string in c

javascript - where 子句上的意外标记 ' : '