如何获得关键价值

时间:2009-11-17 17:33:59

标签: json key

我的示例JSON字符串如下:

{"8776337":{"text":"Test Message","status":"d","created_time":"1244475327","reply_number":"447624800500","completed_time":"1244475373","credits_cost":"0.4"}}

“8776337”是某些API返回的动态密钥。我想使用LINQ to JSON查询来获取此键值。

如何使用LINQ to JSON获取此键值?

1 个答案:

答案 0 :(得分:0)

我知道如何使用javascript获取此值:

function test()
{
var p = {"8776337":{"text":"Test Message","status":"d","created_time":"1244475327","reply_number":"447624800500","completed_time":"1244475373","credits_cost":"0.4"}};
  for (var key in p) {
      if (p.hasOwnProperty(key)) {
        alert(key);
      }
    }
}

然后将它发送到服务器端很容易!