0

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"]
}, {}
]
5
  • 1
    This is a JSON data format, you need to de-serialize it to your object type Commented Jun 7, 2017 at 6:56
  • You might want to start with this: nuget.org/packages/Newtonsoft.Json Commented Jun 7, 2017 at 7:06
  • make sure your web service accept list of that object. Everything will be handled. Say your method is Charge(string chargeArray) convert this to Charge(List<Charge> charge) Commented Jun 7, 2017 at 7:15
  • Please read stackoverflow.com/questions/14640028/…. Commented Jun 7, 2017 at 7:16
  • stackoverflow.com/questions/39461518/… look at this Commented Jun 7, 2017 at 7:22

1 Answer 1

1

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

Install Newtonsoft.Json using below command (In NuGet package manager).

Install-Package Newtonsoft.Json

To deserialize your JsonString to Object List as below.

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

For more Information about Newtonsoft.Json Please visit below link.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.