http://mobsec-dianhua.baidu.com/dianhua_api/open/location?tel=13888888888
返回:
{"response":{"13888888888":{"detail":{"area":[{"city":"昆明"}],"province":"云南","type":"domestic","operator":"移动"},"location":"云南昆明移动"}},"responseHeader":{"status":200,"time":1556446910692,"version":"1.1.0"}}
C# 解析多级JSON 并 获取数据的两种方式:
一、使用JsonConvert.DeserializeObjec
{
var json = JsonConvert.DeserializeObject<dynamic>(jsonStr);
string s = json["response"][number]["location"];
}
二、使用JObject
{
var JObj = JObject.Parse(jsonStr);
string responseStr = JObj["response"].ToString();
var responseObj = JObject.Parse(responseStr);
string rnumberStr = responseObj[number].ToString();
var NumberObj = JObject.Parse(rnumberStr);
string location = NumberObj["location"].ToString();
var detailObj = JObject.Parse(NumberObj["detail"].ToString());
string providerName = detailObj["operator"].ToString();
}