Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Get Json Array in C# ?
    text
    copied!<p>I have a Json String Like this ,, and i wana load it in C# Array .. When i try to do this i am getting Exception </p> <p>My String : </p> <pre><code> { "customerInformation": [ { "customerId":"123", "CustomerName":"", "Age":39, "Gender":"Male", "StudyInfo":[ { "Modality":"XRAY", "StudyName":"Test Name", "ModalityId":"1", "StudyID":"10923", "visitid":41549113, "billingId":"456", "RegDate":"mm/dd/yyyy", "uploaded":"1", "groupid":"1" }, { "Modality":"XRAY", "StudyName":"CT Test Name", "ModalityId":"1", "StudyID":"10924", "visitid":41549113, "billingId":"459", "RegDate":"mm/dd/yyyy", "uploaded":"1", "groupid":"1" } ] }, { "customerId":"928", "CustomerName":"", "Age":49, "Gender":"FeMale", "StudyInfo":[ { "Modality":"XRAY", "StudyName":"Test Name", "ModalityId":"1", "StudyID":"10923", "visitid":41549113, "billingId":"456", "RegDate":"mm/dd/yyyy", "uploaded":"1", "groupid":"1" }, { "Modality":"XRAY", "StudyName":"CT Test Name", "ModalityId":"1", "StudyID":"10924", "visitid":41549113, "billingId":"459", "RegDate":"mm/dd/yyyy", "uploaded":"1", "groupid":"1" } ] } ] } </code></pre> <p>My Code : </p> <pre><code>public class Attributes { public string[] customerId { get; set; } public string[] CustomerName { get; set; } public string[] Age { get; set; } public string[] Gender { get; set; } public string[] StudyInfo { get; set; } public string[] Modality { get; set; } public string[] StudyName { get; set; } public string[] ModalityId { get; set; } public string[] StudyID { get; set; } public string[] visitid { get; set; } public string[] billingId { get; set; } public string[] RegDate { get; set; } public string[] uploaded { get; set; } } public class DataJsonAttributeContainer { public List&lt;Attributes&gt; attributes { get; set; } } public static T DeserializeFromJson&lt;T&gt;(string json) { T deserializedProduct = JsonConvert.DeserializeObject&lt;T&gt;(json); return deserializedProduct; } public void testing() { var container = DeserializeFromJson&lt;DataJsonAttributeContainer&gt;(JsonString); } </code></pre> <p>"This returns Null"</p> <p>And I have tried this also </p> <pre><code> JArray jArray = (JArray)JsonConvert.DeserializeObject(JsonStr); dynamic dynObj1 = jArray.OrderByDescending(x =&gt; x["customerId"]); </code></pre> <p>Both Cases got Failed... How to load this .. I am using Newtonsoft.Json Dll </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload