Skip to content

Commit

Permalink
More forgiving JSON parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarnagiris committed Nov 30, 2014
1 parent 65f801c commit 55d11d7
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;

import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -84,7 +85,9 @@ public BackupDataImporter(InputStream inputStream, Context context, DBHelper dbH

private JsonObject inputStreamToJson(InputStream inputStream) {
final JsonParser parser = new JsonParser();
final JsonElement jsonElement = parser.parse(new InputStreamReader(inputStream));
final JsonReader jsonReader = new JsonReader(new InputStreamReader(inputStream));
jsonReader.setLenient(true);
final JsonElement jsonElement = parser.parse(jsonReader);
return jsonElement.getAsJsonObject();
}

Expand Down

0 comments on commit 55d11d7

Please sign in to comment.