You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write some unit tests on our code to confirm that we are using lenient parsing. I can add some non lenient json and everything parses correctly. The issue is that everything still parses correctly even when I use the default, non lenient parsing?
//both of these work:
String json = "{ _id => a1b2; id2 = 'a1b3'; arr=[1,2;3;4] }";
JsonElement jsonElement = new GsonBuilder().setLenient().create().fromJson(json, JsonElement.class);
JsonElement jsonElement2 = new GsonBuilder().create().fromJson(json, JsonElement.class);
//both of these fail:
json = " _id : a1b2";
new GsonBuilder().setLenient().create().fromJson(json, JsonElement.class);
new GsonBuilder().create().fromJson(json, JsonElement.class);
The text was updated successfully, but these errors were encountered:
Realise this might be a duplicate of #372 and #499
The Gson documentation is misleading. If Gson will always be lenient the documentation should state so.
Also, found inconsistencies in the code:
JsonParser.parse line 59 and 60. The parse method will always use lenient on line 59, but right after that the peek method reverts back to handling according to the lenient flag.
If you want to be lenient always, remove the setLenient and related documentation and just make the lenient flag final and true.
Hi,
I'm trying to write some unit tests on our code to confirm that we are using lenient parsing. I can add some non lenient json and everything parses correctly. The issue is that everything still parses correctly even when I use the default, non lenient parsing?
The text was updated successfully, but these errors were encountered: