110,538
社区成员
发帖
与我相关
我的任务
分享
{"tmall_msf_identify_status_query_response":{"result":"{errorMessage=服务类型不对, gmtCurrentTime=1469153603575, errorCode=352, class=com.tmall.msf.common.dto.Result, object=null, success=false, costTime=null}","request_id":"3jvhmoxlvkco"}}
public class result
{
public string errorMessage { get; set; }
public long gmtCurrentTime { get; set; }
public int errorCode { get; set; }
public string @class { get; set; }
public object @object { get; set; }
public bool success { get; set; }
public object costTime { get; set; }
}
public class tmall_msf_identify_status_query_response
{
public result result { get; set; }
public string request_id { get; set; }
}
tmall_msf_identify_status_query_response obj = JsonConvert.DeserializeObject<tmall_msf_identify_status_query_response>(json);
public class Rootobject
{
public Tmall_Msf_Identify_Status_Query_Response tmall_msf_identify_status_query_response { get; set; }
}
public class Tmall_Msf_Identify_Status_Query_Response
{
public string result { get; set; }
public string request_id { get; set; }
}
你会发现result后边的是在双引号里面的,引号里面的都是result的值 var t = Regex.Replace(x.Value.ToString(), "=([^,}]+)", ":'$1'");
改成这样要好些 var t = Regex.Replace(x.Value.ToString(), "=(null|false|true)", ":$1");
t = Regex.Replace(t, "=([^,}]+)", ":'$1'");
var s = File.ReadAllText("d5.txt", Encoding.Default);
var a = JObject.Parse(s);
foreach (var x in (JObject)a["tmall_msf_identify_status_query_response"])
{
Console.WriteLine("{0} : {1}", x.Key, x.Value);
if (x.Key == "result")
{
//这样转成 json 串
var t = Regex.Replace(x.Value.ToString(), "=([^,}]+)", ":'$1'");
foreach (var y in JObject.Parse(t))
{
Console.WriteLine("{0} : {1}", y.Key, y.Value);
}
}
}