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);
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.