We are having allot issues trying to decode some json which was created in our webservice from json.net
[
{
"id":"12a0910b-0196-4f1b-acff-1d395a32bbd1",
"IVACode":"IVA001",
"FirstName":"David",
"LastName":"Buckley",
"AddressLine1":"1 rathmena gardens ",
"AddressLine2":"",
"Town":"Ballyclare",
"County":"Antrim",
"PostCode":"BT3999HU",
"Telephone":"023828392",
"EmailAddress":"david@gmail.com",
"isActive":true,
"authUserName":null,
"authCreatedDate":"2016-06-27T00:00:00",
"personalProgressValue":5,
"contributionsToDate":null,
"totalContributions":null,
"totalArrears":50000.00,
"totalPaid":null,
"isDeleted":false,
"deviceId":"dwedwedwedwe",
"deviceOs":null
},
{
"id":"7aee450a-a9a7-4f19-83d3-467a3b8a39c0",
"IVACode":"IVA002",
"FirstName":"Peter",
"LastName":"Carson",
"AddressLine1":"Waters Edge Belfast",
"AddressLine2":null,
"Town":"Belfast",
"County":"Down",
"PostCode":"BT99YXX",
"Telephone":null,
"EmailAddress":"peter.carson@company.uk.com",
"isActive":true,
"authUserName":null,
"authCreatedDate":null,
"personalProgressValue":6,
"contributionsToDate":null,
"totalContributions":null,
"totalArrears":50000.00,
"totalPaid":null,
"isDeleted":false,
"deviceId":null,
"deviceOs":null
}
]
So in our web method I have the following to enclode a list which produces the above
[WebMethod]
public string getCustomerInfo()
{
var customerData = _dal.apertureAppstblCustomers.ToList();
var jsonstring = JsonConvert.SerializeObject(customerData);
jsonstring = jsonstring.Replace("<string>", "").Replace("</string>", "");
return jsonstring;
}
But I have validated the json and it says its correct but when i try to decode this method it fails even when i try to enclose it as a string for testing. Obv we used the string json =@ ""; above string
JArray a = JArray.Parse(json);
foreach (JObject o in a.Children<JObject>())
{
foreach (JProperty p in o.Properties())
{
string name = p.Name;
string value = (string)p.Value;
Console.WriteLine(name + " -- " + value);
}
}