How to map JSON response to custom class object

后端 未结 1 1413
花落未央
花落未央 2021-01-03 07:33

I am calling an API in C# using unirest.io. I get following JSON response (as response.Body).

{
    \"persons\": [{
        \"id\": \"a010\",
               


        
相关标签:
1条回答
  • 2021-01-03 08:03

    Pass Persons in Deserialize<T> instead of Vendors

    persons = serializer.Deserialize<Persons>(response.Body);
    

    Rename property

    public PersonInfo[] infos;
    

    To

    public PersonInfo[] persons;
    

    Additionally, I would recommend you to use Auto-properties. i.e.

    public PersonInfo[] persons{get;set;}
    
    0 讨论(0)
提交回复
热议问题