LitJson: Instance of JsonData is not a dictionary错误的解决方法
LitJson: Instance of JsonData is not a dictionary错误的解决方法
有一串这样的JSON字符串
{“errcode”:0,“errmsg”:“ok”,“phone_info”:{“phoneNumber”:“13688888888”,“countryCode”:“86”}}。
正确的解析方法如下:
static void Main(string[] args)
{
string result ="{\"errcode\":0,\"errmsg\":\"ok\",\"phone_info\":{\"phoneNumber\":\"13688888888\",\"countryCode\":\"86\"}}";
JsonData jd = JsonMapper.ToObject(result);
JsonData phoneJson = jd["phone_info"];
string phoneNumber= (string)phoneJson["phoneNumber"];//这里就取到二级json里面的值了
}