I've searched a lot about this problem without finding any appreciable result (maybe because i don't have a clear idea of what to ask), then here we are... I have to design two structures derived from two different JSON which they have common parts:
{
"data":
{
"success": true,
"updated_ids": [0],
"not_updated_ids": [0]
}
}
{
"data":
{
"success": true,
"branch_ids":["0"]
}
}
My idea is to create something like this:
class Response
{
Data data { get; set; }
}
class Data
{
bool success { get; set; }
}
class UserResponse : Data
{
List<int> updatedIds { get; set; }
List<int> notUpdatedIds { get; set; }
}
class BranchResponse : Data
{
List<string> branchIds { get; set; }
}
Now my question is: How can i instantiate my two different classes? If I do new Response()
i don't get the UserReponse
or BranchResponse
part and if i do new UserResponse()
i don't get the Response
part.
Basically i would like to instantiate a variable for each structure, populate it with all the values and then Serialize to create the Json.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire