【问题标题】:How can I retrieve a particular field from JSON object using Node.JS? [duplicate]如何使用 Node.JS 从 JSON 对象中检索特定字段? [复制]
【发布时间】:2020-04-01 15:39:54
【问题描述】:

这是我尝试从中检索字段 TEMP 的 JSON 对象的格式。

[
    [
        {
            "DEVICE_ID": "357807272",
            "TEMP": 20.439
        }
     ]
 ]

【问题讨论】:

    标签: node.js json promise javascript-objects aws-sdk-nodejs


    【解决方案1】:

    使用javascript过滤器检索对象,请在下面找到代码sn-p:

    var heroes = [
    {name: 'Batman', franchise: 'DC'},
    {name: 'Ironman', franchise: 'Marvel'},
    {name: 'Thor', franchise: 'Marvel'},
    {name: 'Superman', franchise: 'DC'}
    ];
    
    var marvelHeroes =  heroes.filter(function(hero) {
     return hero.franchise == 'Marvel';
    });
    console.log(marvelHeroes);
    

    【讨论】:

    • 这对 OP 结构毫无帮助。
    • @Bergi 这是一种暗示性的方法
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 2020-05-09
    • 1970-01-01
    • 2015-08-24
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多