String to JsonElement

17,669 views
Skip to first unread message

Peter

unread,
Sep 20, 2010, 5:39:00 AM9/20/10
to google-gson
I've had a hunt through the API and can't spot a way to do

String jsonString = "{\"a\":\"b\"}";
JsonElement jsonElement = SomeGsonObject.toJsonElement(jsonString);

What am I missing?

Cheers,
Peter

nige....@googlemail.com

unread,
Sep 24, 2010, 5:23:52 AM9/24/10
to google-gson
JsonElement = new JsonParser.parse(jsonString);

Eli Kohanchi

unread,
Jul 29, 2014, 1:45:05 PM7/29/14
to googl...@googlegroups.com, nige....@googlemail.com
Actually i think it would be something like this...

JsonElement response = new JsonParser().parse(jsonString);
Reply all
Reply to author
Forward
0 new messages