0

I'm receiving the following error when I attempt to deserialize JSON text:

Unexpected character encountered while parsing value: {. Path '[0]', line 1, position 3.

The JSON Text validated properly using JSONLint.com, here is the JSON text:

[
    [
        {"trackingNo":"R2E2003100011429","eventTime":1479184076000,"eventCode":"INF","activity":"Shipping Information received by Australia Post","location":"","referenceTrackingNo":null},
        {"trackingNo":"R2E2003100011429","eventTime":1479186149000,"eventCode":"INF","activity":"Shipping Information approved by Australia Post","location":"","referenceTrackingNo":null},
        {"trackingNo":"R2E2003100011429","eventTime":1479448620000,"eventCode":"SCN","activity":"Departed facility","location":"","referenceTrackingNo":null}
    ],
    [
        {"trackingNo":"HBF0003142011420","eventTime":1478666798000,"eventCode":"INF","activity":"Shipping Information received by Australia Post","location":"","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1478732453000,"eventCode":"INF","activity":"Shipping Information approved by Australia Post","location":"","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1478932980000,"eventCode":"SCN","activity":"Departed facility","location":"","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1479082255000,"eventCode":"SCN","activity":"Arrived at facility in destination country","location":"","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1479082261000,"eventCode":"CCD","activity":"Cleared by customs","location":"","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1479124118000,"eventCode":"SCN","activity":"Processed through Australia Post facility","location":"CHULLORA NSW","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1479236805000,"eventCode":"SCN","activity":"With Australia Post for delivery today","location":"KINGSGROVE NSW","referenceTrackingNo":null},
        {"trackingNo":"HBF0003142011420","eventTime":1479248135000,"eventCode":"DLD","activity":"Delivered","location":"CARINGBAH NSW","referenceTrackingNo":null}
    ]
]

Here is my code:

                    using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
                        {
                            string text = reader.ReadToEnd();
                                List<string[]> trackingResponse = JsonConvert.DeserializeObject<List<string[]>>(text);
//    ...Do some stuff...

        }

1 Answer 1

2

The type you should use is List<List<SomeObject>>

var result = JsonConvert.DeserializeObject<List<List<SomeObject>>>(json);


public class SomeObject
{
    public string trackingNo { get; set; }
    public long eventTime { get; set; }
    public string eventCode { get; set; }
    public string activity { get; set; }
    public string location { get; set; }
    public string referenceTrackingNo { get; set; }
}
Sign up to request clarification or add additional context in comments.

2 Comments

LB whats the best method to access contents
For ex., result[0][0].trackingNo

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.