Reputation: 305
In my project i have to implement login with gmail and storing data into datastore(bigtable),but i got an exception,error code is 500.
com.google.gson.stream.MalformedJsonException:
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12 path $
The line number is 88 and the code is:
JsonObject json = (JsonObject)new JsonParser().parse(outputString.trim());
String access_token = json.get("access_token").getAsString();
System.out.println(access_token);
Upvotes: 1
Views: 2488
Reputation: 2021
Instead of using JsonObject, try Gson library to convert from Json to String and vice versa. For a thorough example, see this answer.
If you first create a response class and then serialize it with Gson (like shown in that answer), then you make sure that you are creating a well formatted Json String.
Upvotes: 4