The Json body I want to deserialize is something like below
{
"status": "OK",
"place_id": "07e0a63d862b2982e4c4b7e655f148d2",
"scope": "APP"
}
Below is the Json body I want to build from above Json after deserializing it
{
"place_id": "07e0a63d862b2982e4c4b7e655f148d2"
}
Because your JSON data appears to be rather small you could use Gson's
JsonParser.parseString(String)
method to parse the data into an in-memory representation, then copy the relevant JSON object member to a newJsonObject
and serialize that to JSON usingGson.toJson(JsonElement)
:If this solution turns out to not be efficient enough for you, you could also have a look at
JsonReader
andJsonWriter
.