110,533
社区成员
发帖
与我相关
我的任务
分享
{
"binary": 0,
"channel": "ok_sub_spot_EOS_ETH_depth_10",
"data": {
"asks": [
[ "0.01347406", "50" ],
[ "0.01347405", "12.5832154" ],
[ "0.01346003", "19.7706985" ],
[ "0.0134513", "3.109" ],
[ "0.01345", "3.38235927" ]
],
"bids": [
[ "0.01331194", "17.8021832" ],
[ "0.01331193", "116.553" ],
[ "0.01329865", "88" ],
[ "0.01329864", "106.77401213" ],
[ "0.01328515", "132" ]
],
"timestamp": 1516873105061
}
}
假设我要取asks下面第二行的 [ "0.01347405", "12.5832154" ],我这样写报错了,正确的是怎么操作?JObject 成员=上面那段json字符串;
Single asks第二行的第一个 = (Single)成员["data"]["asks"][1][0];
Single asks第二行的第二个 = (Single)成员["data"]["asks"][1][1];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string json = "{\"binary\": 0,\"channel\": \"ok_sub_spot_EOS_ETH_depth_10\",\"data\": {\"asks\": [[ \"0.01347406\", \"50\" ],[ \"0.01347405\", \"12.5832154\" ],[ \"0.01346003\", \"19.7706985\" ],[ \"0.0134513\", \"3.109\" ],[ \"0.01345\", \"3.38235927\" ]],\"bids\": [[ \"0.01331194\", \"17.8021832\" ],[ \"0.01331193\", \"116.553\" ],[ \"0.01329865\", \"88\" ],[ \"0.01329864\", \"106.77401213\" ],[ \"0.01328515\", \"132\" ]],\"timestamp\": 1516873105061}}";
JObject obj = JObject.Parse(json);
Console.WriteLine(obj["data"]["asks"][1]);
}
}
}