Tôi có phản hồi json ở định dạng dưới đây.Json: làm thế nào để đúng cách tách các ký tự thoát với json.net
"[{\\\"JobID\\\":\\\"1\\\",\\\"BillGenerationDate\\\":\\\"4/29/2013 2:53:34 PM\\\",\\\"BillID\\\":\\\"115743\\\",\\\"BillNo\\\":\\\"115743\\\",\\\"CustomerID\\\":\\\"4041705\\\",\\\"PayStatus\\\":\\\"0\\\",\\\"PaymentRequiredStatus\\\":\\\"True\\\",\\\"ProductName\\\":\\\"Epic FBO test\\\",\\\"Description\\\":\\\"Epic Automation 2\\\\r\\\\n\\\",\\\"ProductType\\\":\\\"eBill \\\",\\\"DueType\\\":\\\"-1\\\",\\\"DueDate\\\":\\\"2013-03-15\\\",\\\"Amount\\\":\\\"63.70\\\",\\\"Cost\\\":\\\"\\\"},
{\\\"JobID\\\":\\\"9\\\",\\\"BillGenerationDate\\\":\\\"5/2/2013 10:21:39 AM\\\",\\\"BillID\\\":\\\"115743\\\",\\\"BillNo\\\":\\\"115743\\\",\\\"CustomerID\\\":\\\"4041705\\\",\\\"PayStatus\\\":\\\"0\\\",\\\"PaymentRequiredStatus\\\":\\\"True\\\",\\\"ProductName\\\":\\\"FBO Test Product\\\",\\\"Description\\\":\\\"FBO Product Test\\\",\\\"ProductType\\\":\\\"eBill \\\",\\\"DueType\\\":\\\"-1\\\",\\\"DueDate\\\":\\\"2013-05-01\\\",\\\"Amount\\\":\\\"150.70\\\",\\\"Cost\\\":\\\"\\\"}]
Tôi tin json.net xử lý các ký tự thoát và tôi đã sử dụng mã bên dưới để deserialize nó vào bộ sưu tập từ điển.
var billList = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(contentCorrected);
Nhưng phân tích json này ném ngoại lệ "không hợp lệ nhận dạng sở hữu nhân vật: Đường dẫn '[0]', dòng 1, vị trí 2.". Chúng ta có thể giải quyết điều này bằng cách thao tác chuỗi phản ứng json không?
Cảm ơn Bijoy .... làm việc của nó ..... Cảm ơn –
Nó phải là như 'contentCorrected = contentCorrected.Replace (@ "\" "" , @ "" "") ' – msa7
hoặc ' contentCorrected = contentCorrected.Replace (@ "\", string.Empty) ' –