0

I am new to json.net. My Json looks like below. I need to access status in the json.Please let me know how to get it.

{
"msg_id": "8923-15323-1332c61-1674bfd2872-5232e550-49204213240",
"sendondate": "2013-09-13 15:43:00",
"seq_id": {
    "1": {
        "valid": "true",
        "credit": "1.00",
        "linecount": 1,
        "billcredit": 1,
        "id_provider": "2",
        "providerkey": "AT",
        "regionKey": "AP",
        "mnpID": "52",
        "dlr_seq": 1,
        "status": "DELIVER",
        "remarks": ""
    }
}
}

Code :

var data = JsonConvert.DeserializeObject<T>(datastring);

When I am using this , I got error msg Unexpected token: StartObject. Pls help me.

Thanks

1 Answer 1

1

Use this code

public class Response
{

    [JsonProperty("msg_id")]
    public string MsgId { get; set; }

    [JsonProperty("sendondate")]
    public string Sendondate { get; set; }

    [JsonProperty("seq_id")]
    public SeqId SeqId { get; set; }
}

public class SeqId
{

    [JsonProperty("1")]
    public Class1 value { get; set; }
}

public class Class1
{

    [JsonProperty("valid")]
    public string Valid { get; set; }

    [JsonProperty("credit")]
    public string Credit { get; set; }

    [JsonProperty("linecount")]
    public int Linecount { get; set; }

    [JsonProperty("billcredit")]
    public int Billcredit { get; set; }

    [JsonProperty("id_provider")]
    public string IdProvider { get; set; }

    [JsonProperty("providerkey")]
    public string Providerkey { get; set; }

    [JsonProperty("regionKey")]
    public string RegionKey { get; set; }

    [JsonProperty("mnpID")]
    public string MnpID { get; set; }

    [JsonProperty("dlr_seq")]
    public int DlrSeq { get; set; }

    [JsonProperty("status")]
    public string Status { get; set; }

    [JsonProperty("remarks")]
    public string Remarks { get; set; }
}

Then write

 var obj = JsonConvert.DeserializeObject<Response>(Your_String);
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.