Skip to content

fromJson Json to String JsonSyntaxException #686

@300682

Description

@300682

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 13 path $
at com.google.gson.Gson.assertFullConsumption(Gson.java:786)
at com.google.gson.Gson.fromJson(Gson.java:776)
at com.google.gson.Gson.fromJson(Gson.java:724)
at com.inspeed.commons.tools.GsonTools.fromJson(GsonTools.java:19)
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 13 path $
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1574)
at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1424)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:547)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:429)
at com.google.gson.Gson.assertFullConsumption(Gson.java:782)
... 27 more

test code below
String timeStr=GsonTools.fromJson("2015-08-14 10:30:20",String.class);

my view the source code of the STRING TypeAdapter is called found JsonReader nextString ( ) go to nextUnquotedValue() This method is positioned to see the case' ' : Will break, why?

if Use JsonReader.setLenient(true) the result is 2015-08-14,This is not the result I want.

my expect value is '2015-08-14 10:30:20'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions