Hello all I am new to JSON deserialize. this is the JSON data which has to be deserialized to .net objects so that I can store those values from JSON in the database.
This my code:
var client = newRestClient("https:xxxxxxxxxxxxxxxxxx/pincodes/");
var request = new RestRequest(Method.POST);
request.AddHeader("Postman-Token", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\xxxxxxxxxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\xxxxxxxxxxxxxxxx\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string JsonContent = response.Content;
this how json file looks like:
[{"city": "AMBALA", "state": "Haryana", "city_type": "", "active": true, "route": "HR/I1H/ABA", "date_of_discontinuance": "", "state_code": "HR", "pincode": 134003, "city_code": "ABA", "dccode": "ABA"},
{"city": "AMBALA", "state": "Haryana", "city_type": "", "active": true, "route": "HR/I1H/ABA", "date_of_discontinuance": "", "state_code": "HR", "pincode": 134002, "city_code": "ABA", "dccode": "ABA"}]
I want to access specific values ex. value of city, pincodes
etc.
How to create a model, I tried but getting some error: "Error CS0825 The contextual keyword 'var' may only appear within a local variable declaration or in script code"