1、简单的获取某个键值
JToken jtoken = JToken.Parse(jsonStr);string jsjid = jtoken.Value("JSJID");
多层次对象解析
string json = KTHttpRequest._Post(AirwayKeeperModel.YiChengNewMemberUrl, "_OperateMemberOraInfo", new { CommandStr = "delete_user_info", Mobile = nMobile }); var jtoken = JToken.Parse(json); if (null != jtoken) { var baseRes = jtoken.Value("BaseResponse"); if (null != baseRes) { if (baseRes.Value ("IsSuccess")) return true; throw new JSJException(baseRes.Value ("ErrorMessage")); } } return false;
2、序列化
object nPostData = new { BaseRequest = new BaseRequest(), JSJID = 9527 };string json = Newtonsoft.Json.JsonConvert.SerializeObject(nPostData);
3、反序列化
string tmp = KTHttpRequest._Post(m_ConfigModel.WShareUrl, "_GetCodeStrByOrderNum", new { OrderNum = orderNum, }); var response = Newtonsoft.Json.JsonConvert.DeserializeObject(tmp);