【发布时间】:2014-08-26 10:32:05
【问题描述】:
我有以下 Json 字符串。我想使用'Key'来获取'Value',比如
给出 'BtchGotAdjust' 会返回 'Batch Got Adjusted';
var jsonstring=
[{"Key":"BtchGotAdjust","Value":"Batch Got Adjusted"},{"Key":"UnitToUnit","Value":"Unit To Unit"},]
【问题讨论】:
-
像数组一样访问它?还是我把你的问题弄错了?
-
您需要遍历您的对象数组并比较或使用像 underscoreJS 这样的库,这使得它变得简单快捷:
_.findWhere(list, properties) -
@Ahmad 你可以使用纯js,不需要其他库。
-
@Magrangs 我们可以肯定地用纯 js 做任何事情,但我们大多数人仍然使用它们来节省时间:)
-
@Ahmad 同意,但这只是一个简单的问题,在这种情况下添加库是多余的。
标签: javascript jquery asp.net-mvc json