asp.net mvc - How to ues JsonConvert.DeserializeObject to convert array to Model in C# -
there data.
how convert model?
{"test": ["123","456"]}
if have json string , want map c# class construct can use intigrated visual studio function paste json classes.
- copy json
- select edit –> paste special –> paste json classes
if visual studio make class:
public class rootobject { public string[] test { get; set; } }
to deserialize call:
var json = "{\"test\": [\"123\",\"456\"]}"; var myobject = jsonconvert.deserializeobject<rootobject>(json);
Comments
Post a Comment