How Do I Configure Json.NET Custom Serialization?

后端 未结 3 600
有刺的猬
有刺的猬 2021-01-21 04:47

For reasons beyond my control, I have data coming back from an external service being formatted as an array of array of string: [[\"string_one\", \"string_two\"]]

3条回答
  •  伪装坚强ぢ
    2021-01-21 05:37

    There is quite a big discrepancy between your target object and the JSON. You could do the mapping manually:

    string json = "[[\"string_one\", \"string_two\"]]";
    dynamic result = JsonConvert.DeserializeObject(json);
    var myObject = new MyObject
    {
        PropertyOne = result[0][0],
        PropertyTwo = result[0][1]
    };
    

提交回复
热议问题