【问题标题】:C# looping array object multidimensional from ajax postC#从ajax post循环数组对象多维
【发布时间】:2017-11-08 09:19:19
【问题描述】:

我有多维数组对象如何在 c# 中循环所有值? 在 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"]}

阿贾克斯

    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"]
}, {}
]

【问题讨论】:

标签: c# multidimensional-array ajaxform


【解决方案1】:

我认为你应该如下制作模型类。

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; }
}

使用以下命令安装 Newtonsoft.Json(在 NuGet 包管理器中)。

Install-Package Newtonsoft.Json

将您的 JsonString 反序列化为对象列表,如下所示。

List<string> listOfObjects = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Charge>>(yourJsonStringHere);

有关 Newtonsoft.Json 的更多信息,请访问以下链接。

http://www.newtonsoft.com/json/help/html/Introduction.htm

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-07
    • 1970-01-01
    • 2016-10-05
    • 2019-12-29
    • 1970-01-01
    • 2013-05-29
    • 2020-05-15
    • 1970-01-01
    相关资源
    最近更新 更多