How to use System.Text.Json to parse a nested object.

  • Thread starter Thread starter zydjohn
  • Start date Start date
Z

zydjohn

Guest
Hello,
I want to know how to parse/deserialize a string to an object.
I have to following data structure and one json string with the data structure:

public class AccountData
{
public int account_id { get; set; }
public double rate { get; set; }
public List<object> balance { get; set; }
public bool account_open { get; set; }
}

string account_data =
@"{""account_id"":123456,""rate"":1.0,""balance"":[""GBP"",10000.0],""account_open"":true}";

I want to write a function to parse the json string (account_data) to an object (class AccountData) using System.Text.Json.
I can't see good example for this.
Thanks,

Continue reading...
 
Back
Top