Reputation: 307
I have several services that return three fields (json). FailureMessage (string, in case something wrong happens) Success (boolean) [Custom] (object of return) Examples below:
1)
{
"FailureMessage": "",
"Success": true,
"Cities": []
}
2)
{
"FailureMessage": "",
"Success": true,
"Regions": []
}
Is there a way to map then in a generic way?
Now, I have the first 2 properties mapped to a GenericResponse, and other classes extending GenericResponse and creating the third attribute in each one.
Thanks in advance
Upvotes: 0
Views: 3260
Reputation: 2644
This should be usable as a solution to your problem.
You will have to provide gson with a method of parsing your specific structure.
Upvotes: 3