Im using GSON on an Android device.
I have JSON data coming in, but it can come in the form of a few different objects.
This is how I think I need to handle it.
public class Command
{
public String Command;
}
String json = {"Command":"Something", "date":"now"}
String command = gson.fromJson(message, Command.class);
Then switch on command
Switch(command)
{
case: something
//deserialize to "something" object;
break;
case: other somthing
//deserialize to "other somthing" object;
break;
case: object 3
//deserialize to "object 3" object;
break;
}
Does GSON have some sort of Auto Mapping to the best suited object, so i dont have to make a custom object handler and deseraialize the String twice?