JsonReader.setLenient(true)を使用して、不正な形式のJSONを受け入れます



Use Jsonreader Setlenient Accept Malformed Json



現在プロジェクトでRetrofit2を使用している場合、発生する問題は次のとおりです。

rx.exceptions.OnErrorNotImplementedException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 1 path

解決:
このエラーは、json文字列の形式が正しくない場合に発生します。 jsonフォーマットエラーの場所を簡単に見つけることができない場合は、GSON解析モードを寛容モードに設定することもできます。



Gson gson = new Gson() JsonReader reader = new JsonReader(new StringReader(result1)) reader.setLenient(true) Userinfo userinfo1 = gson.fromJson(reader, Userinfo.class)

元の:
http://stackoverflow.com/questions/11484353/gson-throws-malformedjsonexception