Json.NET: serializing/deserializing arrays

前端 未结 2 1815
小鲜肉
小鲜肉 2021-01-05 17:00

I\'m using a Json.NET library. What\'s the most convenient way of serializing/deserializing arrays in JSON via C#? For example, I\'m trying to deserialize the following text

2条回答
  •  粉色の甜心
    2021-01-05 17:58

    The Favorite_numbers property is going to be of type JArray since there is no way for it to infer what type it should be. The most convenient way of deserializing that object is going to be to define a C# class for it and use the JsonConvert.DeserializeObject(...) method(s) to deserialize the JSON to your defined class.

提交回复
热议问题