I know it's probably very trivial question but I can't seem to find an answer online..
Imagine I have a below JSON
{"userId" : "myUser","sites" : ["site1", "site2"] }
I would like to parse it to C# object User
but RestSharp
parser is failing to parse array correctly.
I tried implementing sites
as below:
public string[] sites = new string[5];
public List<string> sites;
but nothing seems to work.
For deserialization I use
JsonDeserializer deserial = new JsonDeserializer();
User newUser = new User();
newUser = deserial.Deserialize<user>(response);
--> response is a
IRestResponse
object.
The code is correctly parsing the simple strings like userId
but it's struggling with arrays...
What I am doing wrong? Is RestSharp
not the right tool to do that?
What in case the is an object array in Json like
{"userImgs" : {"small": "https://myImage.co.uk/small", "large" : "https://myImage.co.uk/large"}}
Could I just have an object with an object as property an would the parser handle that if I implemented my class as below?
Class User{
string userId;
UserImages userImg = new UserImages();
Thanks