C# json转对象
2021-05-17 11:28
标签:tac net dig eric str expect ace memory bin EnterpriseResponse09.json TestResponse.cs EnterpriseResponse09.cs DataContractJsonSerializer C# json转对象 标签:tac net dig eric str expect ace memory bin 原文地址:https://www.cnblogs.com/hofmann/p/11776020.html{
"response_biz_content": {
"MSG": "OK",
"return_msg": "OK",
"msg_id": "637067564513056852",
"DATA": [{
"SIZE": 1,
"TCONF": {
"C_EFFECTIVE_FLAG": "案件状态",
"C_CASE_CODE": "案号",
"C_SEX_NAME": "性别",
"C_AREA_NAME": "地域名称",
"C_GIST_UNIT": "作出执行依据单位",
"C_BUESINESSENTITY": "企业法人姓名",
"N_PARTY_TYPE_NAME": "标识自然人或企业法人",
"D_DATA_DATE": "数据日期",
"UNPERFORM_PART": "未履行部分",
"N_AGE": "年龄",
"PERFORMED_PART": "已履行部分",
"C_PERFORMANCE": "被执行人的履行情况",
"D_REG_DATE": "立案时间",
"DUTY": "法律生效文书确定的义务",
"C_INAME": "失信被执行人姓名/名称",
"D_PUBLISH_DATE": "发布时间",
"C_CARDNUM": "身份证号码/组织机构代码",
"C_DISREPUT_TYPE_NAME": "失信被执行人具体情形",
"C_COURT_NAME": "执行法院",
"N_AREA_ID": "地域ID",
"C_GIST_CID": "执行依据文号"
},
"MODEL": "09",
"RISKTYPE": "失信被执行人",
"RISKTYPEDES": "存在通过各种方法拒不执行法院判决的行为,俗称“老赖”。",
"TOTALCOUNT": 1,
"TDATA": [{
"C_EFFECTIVE_FLAG": "1",
"C_CASE_CODE": "(2008)沪213232法执字第01109号",
"C_SEX_NAME": "",
"C_AREA_NAME": "上海",
"C_GIST_UNIT": "厦门市集美区人民法院",
"C_BUESINESSENTITY": "李国华",
"N_PARTY_TYPE_NAME": "",
"D_DATA_DATE": "20190816",
"UNPERFORM_PART": "",
"N_AGE": "0",
"PERFORMED_PART": "",
"C_PERFORMANCE": "全部未履行",
"D_REG_DATE": "20080902",
"DUTY": "",
"C_INAME": "79757239202-0",
"D_PUBLISH_DATE": "20150106",
"C_CARDNUM": "",
"C_DISREPUT_TYPE_NAME": "其他有履行能力而拒不履行生效法律文书确定义务",
"C_COURT_NAME": "上海市浦东新区人民法院",
"N_AREA_ID": 672,
"C_GIST_CID": "(2008)沪法执字第01109号"
}]
}],
"return_code": "0000",
"CODE": "02-000-203-0000"
},
"sign": "H8ESG0qXjYqZaA+rVcY0akVItL74kP11Mb2N4ZaABqL6/FZhU4HfxxKnn9NKU/DDbuIms7Udc89hqmWCzUMDIgKmbisvqimIddjj1RcLNEtiIxgbSwbCmb1KeEFw9gSZiS+7T6kzA86LuFw1IlJRIxU3DBxPzArY88+6RyZmyBQ="
}
using System;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
[Serializable, DataContract]
public class IcbcResponse
{
[DataMember]
private int return_code = -1;
[DataMember]
private string return_msg = "unexpected error.";
[DataMember]
private string msg_id;
public string getMsgId()
{
return this.msg_id;
}
public int getReturnCode()
{
return this.return_code;
}
public string getReturnMsg()
{
return this.return_msg;
}
public bool isSuccess()
{
return (this.return_code == 0);
}
public void setMsgId(string value)
{
this.msg_id = value;
}
public void setReturnCode(int value)
{
this.return_code = value;
}
public void setReturnMsg(string value)
{
this.return_msg = value;
}
[DataMember]
public string MSG { get; set; }
[DataMember]
public string CODE { get; set; }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Entity.Response.Enterprise
{
public class EnterpriseResponse09 : TestResponse
{
[DataMember]
public List
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
string jsonfile = Path.Combine(baseDirectory, "EnterpriseResponse09.json");
string responseJson = string.Empty;
using (StreamReader r = new StreamReader(jsonfile))
{
responseJson = r.ReadToEnd();
}
string response_biz_content = "response_biz_content";
int startIndex = (responseJson.IndexOf(response_biz_content) + response_biz_content.Length) + 2;
string content = responseJson.Substring(startIndex, responseJson.LastIndexOf(",") - startIndex);
EnterpriseResponse09 response = null;
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
response = (EnterpriseResponse09)new DataContractJsonSerializer(typeof(EnterpriseResponse09)).ReadObject(stream);
}
//responseJson = "{\"response_biz_content\":{\"MSG\":\"OK\",\"return_msg\":\"OK\",\"msg_id\":\"637067564513056852\",\"DATA\":[{\"SIZE\":1,\"TCONF\":{\"C_EFFECTIVE_FLAG\":\"案件状态\",\"C_CASE_CODE\":\"案号\",\"C_SEX_NAME\":\"性别\",\"C_AREA_NAME\":\"地域名称\",\"C_GIST_UNIT\":\"作出执行依据单位\",\"C_BUESINESSENTITY\":\"企业法人姓名\",\"N_PARTY_TYPE_NAME\":\"标识自然人或企业法人\",\"D_DATA_DATE\":\"数据日期\",\"UNPERFORM_PART\":\"未履行部分\",\"N_AGE\":\"年龄\",\"PERFORMED_PART\":\"已履行部分\",\"C_PERFORMANCE\":\"被执行人的履行情况\",\"D_REG_DATE\":\"立案时间\",\"DUTY\":\"法律生效文书确定的义务\",\"C_INAME\":\"失信被执行人姓名/名称\",\"D_PUBLISH_DATE\":\"发布时间\",\"C_CARDNUM\":\"身份证号码/组织机构代码\",\"C_DISREPUT_TYPE_NAME\":\"失信被执行人具体情形\",\"C_COURT_NAME\":\"执行法院\",\"N_AREA_ID\":\"地域ID\",\"C_GIST_CID\":\"执行依据文号\"},\"MODEL\":\"09\",\"RISKTYPE\":\"失信被执行人\",\"RISKTYPEDES\":\"存在通过各种方法拒不执行法院判决的行为,俗称“老赖”。\",\"TOTALCOUNT\":1,\"TDATA\":[{\"C_EFFECTIVE_FLAG\":\"1\",\"C_CASE_CODE\":\"(2008)沪213232法执字第01109号\",\"C_SEX_NAME\":\"\",\"C_AREA_NAME\":\"上海\",\"C_GIST_UNIT\":\"厦门市集美区人民法院\",\"C_BUESINESSENTITY\":\"李国华\",\"N_PARTY_TYPE_NAME\":\"\",\"D_DATA_DATE\":\"20190816\",\"UNPERFORM_PART\":\"\",\"N_AGE\":\"0\",\"PERFORMED_PART\":\"\",\"C_PERFORMANCE\":\"全部未履行\",\"D_REG_DATE\":\"20080902\",\"DUTY\":\"\",\"C_INAME\":\"79757239202-0\",\"D_PUBLISH_DATE\":\"20150106\",\"C_CARDNUM\":\"\",\"C_DISREPUT_TYPE_NAME\":\"其他有履行能力而拒不履行生效法律文书确定义务\",\"C_COURT_NAME\":\"上海市浦东新区人民法院\",\"N_AREA_ID\":672,\"C_GIST_CID\":\"(2008)沪法执字第01109号\"}]}],\"return_code\":\"0000\",\"CODE\":\"02-000-203-0000\"},\"sign\":\"H8ESG0qXjYqZaA+rVcY0akVItL74kP11Mb2N4ZaABqL6/FZhU4HfxxKnn9NKU/DDbuIms7Udc89hqmWCzUMDIgKmbisvqimIddjj1RcLNEtiIxgbSwbCmb1KeEFw9gSZiS+7T6kzA86LuFw1IlJRIxU3DBxPzArY88+6RyZmyBQ=\"}";
上一篇:c#服务端图片打包下载