I have a json that looks like this
{"abcd": {
"id": 1234,
"response": "authenticated",
"key": "abrakadaba",
"userId": 5555
}}
and a class that looks like this:
public class Login
{
@SerializedName("response")
public String response;
@SerializedName("userId")
public int userId;
@SerializedName("id")
public int employeeId;
@SerializedName("key")
public String key;
}
This normally works, but not with a json that has the {"abcd": {}} before all the info i need to retrieve.
how do I handle this `”abcd” tag to find and serialize all the other values.
You’ll need something to wrap the Login to coincide with the “abcd”. gson/jackson/whatever is going to want to parse that first. You could create a new class that contains a Login. If that wrapper class is truly going to be throw-away then you may want to just have it parse a
Map<String, Login>and then do a myParsedMap.get(“abcd”) to get your Login object.