如何从NodeJS JSON中的特定键获取值 [英] How to get value from specific key in NodeJS JSON

查看:796
本文介绍了如何从NodeJS JSON中的特定键获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

{
    "id": 83,
    "key": "hello",
    "en": "Hello",
    "mm": "This is greeting",
    "created_at": "2016-12-05T10:14:02.928Z",
    "updated_at": "2017-01-31T02:57:11.181Z"
}

我正在尝试从NodeJS中的mm键获取值.我试图获取translation["mm"],但它根本不起作用.请帮助我如何从上述数据中获取mm.

I'm trying to get value from mm key in NodeJS. I've tried to get translation["mm"] but it does not work at all. Please help me how to get mm from above data.

我当前的节点版本是5.11

推荐答案

编辑了答案.现在,它适用于上述有问题的对象

您可以使用以下功能访问JSON的键.我已经专门返回了"mm"键.

You can use following function to access the keys of JSON. I have returned 'mm' key specifically.

    function jsonParser(stringValue) {

       var string = JSON.stringify(stringValue);
       var objectValue = JSON.parse(string);
       return objectValue['mm'];
    }

这篇关于如何从NodeJS JSON中的特定键获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆