Gson: Directly convert String to JsonObject (no POJO)
use JsonParser; for example:
JsonObject o = JsonParser.parseString("{\"a\": \"A\"}").getAsJsonObject();
Try to use getAsJsonObject()
instead of a straight cast used in the accepted answer:
JsonObject o = new JsonParser().parse("{\"a\": \"A\"}").getAsJsonObject();