本文介绍了C#循环数组对象从Ajax发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有多维数组对象如何在c#中循环所有值?在C#中
I have Multidimensional array object How to loop all value in c# ?in C#
charge[0]{[ChargeMultiId, da95aad9-0cdc-40bb-a5db-3bc0933dea4a ]}
charge[1]{[ChargeMultiNoteslist, Testing notes 29/04/2016 ]}
charge[22]{[Diagnosis, : ["1", "2", "3", "4", "5", "6", "7", "8", "9"]}
Ajax
charge =
"ChargeMultiId": "da95aad9-0cdc-40bb-a5db-3bc0933dea4a",
"ChargeMultiNoteslist": "Testing notes 29/04/2016",
"ChargeMultiCode": "99238",
"ChargeMultiCodeName": "HOSP DSCHRG D MGMT 30 MIN/ < > & '",
"ChargeMultiProcedureID": "89c5ecaf-903b-41d7-8564-e4034d94934f",
"Diagnosis": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
}, {}
]
推荐答案
我认为您应该按如下所示制作模型类.
I think you should make the model class as below.
public class Charge
{
public Guid ChargeMultiId { get; set; }
public string ChargeMultiNoteslist { get; set; }
public int ChargeMultiCode { get; set; }
public string ChargeMultiCodeName { get; set; }
public Guid ChargeMultiProcedureID { get; set; }
public List<int> Diagnosis { get; set; }
}
使用以下命令(在NuGet程序包管理器中)安装Newtonsoft.Json.
Install Newtonsoft.Json using below command (In NuGet package manager).
Install-Package Newtonsoft.Json
如下所示将JsonString反序列化为对象列表.
To deserialize your JsonString to Object List as below.
List<string> listOfObjects = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Charge>>(yourJsonStringHere);
有关Newtonsoft.Json的更多信息,请访问下面的链接.
For more Information about Newtonsoft.Json Please visit below link.
http://www.newtonsoft.com/json/help/html/Introduction.htm
这篇关于C#循环数组对象从Ajax发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!