JSON.net: how to deserialize without using the default constructor?

后端 未结 5 1904
天涯浪人
天涯浪人 2020-11-22 07:21

I have a class that has a default constructor and also an overloaded constructor that takes in a set of parameters. These parameters match to fields on the object and are a

5条回答
  •  太阳男子
    2020-11-22 07:32

    Solution:

    public Response Get(string jsonData) {
        var json = JsonConvert.DeserializeObject(jsonData);
        var data = StoredProcedure.procedureName(json.Parameter, json.Parameter, json.Parameter, json.Parameter);
        return data;
    }
    

    Model:

    public class modelname {
        public long parameter{ get; set; }
        public int parameter{ get; set; }
        public int parameter{ get; set; }
        public string parameter{ get; set; }
    }
    

提交回复
热议问题