0

My RootObject

       [JsonProperty("status")]
        public string Status {
            get;
            set;
        }
        [JsonProperty("error")]
        public ErrosHelper Error {
            get;
            set;
        }
        [JsonProperty("resource")]
        public List<List<int>> Resource {
            get;
            set;
        }

Json response.

{"status":"success","resource":{"1":{"1":"30","2":"23","3":"43"},"2":{"1":"34","2":"54","3":"32"},"3":{"1":"56","2":"43","3":"39"},"4":{"1":"23","2":"32","3":"31"},"5":{"1":"34","2":"37","3":"29"},"6":{"1":"38","2":"34","3":"45"},"7":{"1":"67","2":"53","3":"67"},"8":{"1":"45","2":"23","3":"78"},"9":{"1":"54","2":"44","3":"56"},"10":{"1":"46","2":"23","3":"45"},"11":{"1":"77","2":"56","3":"78"},"12":{"1":"34","2":"21","3":"65"},"13":{"1":"46","2":"23","3":"45"},"14":{"1":"77","2":"56","3":"78"},"15":{"1":"34","2":"21","3":"65"},"16":{"1":"46","2":"23","3":"45"},"17":{"1":"77","2":"56","3":"78"},"18":{"1":"34","2":"21","3":"65"},"19":{"1":"46","2":"23","3":"45"},"20":{"1":"77","2":"56","3":"78"}}}

I have response , that give me Json string. How do I can deserialise this string to my object?

1
  • 1
    Edited. Read question below. Commented Jul 3, 2014 at 7:36

1 Answer 1

4

Your object is wrong. The JSON you are showing does not have a list of lists of int, but rather dictionary of dictionaries.

If you change it to

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

    [JsonProperty("resource")]
    public Dictionary<string, Dictionary<string, int>> Resource {
        get;
        set;
    }
}

It will deserialize correctly using JsonConvert.DeserializeObject<Root>(json);

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks u very much.This exactly what i`m looking for.

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.