Problem with large size JSON on android [closed]

2

I'm getting a JSON file from a WebService, this file comes with the approximate size of 5.7M, so when I'm going to convert your content to JsonArray using the Gson library, it gives me the error:

  

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 4045314

But the file is correct, when I generate the same file with a slightly smaller amount of content (1.8M), the routine works normally, does anyone know why this occurs, is there a known solution?

Follow the code used:

 JsonParser  parser = new JsonParser();
 JsonElement elem   = parser.parse( json.getString("webservice") ); //O erro ocorre aqui;
 JsonArray resultado2 = elem.getAsJsonArray();
 int len = resultado2.size();
Okay, everybody, excuse me. I found the problem. The file was coming corrupted did not download completely, when I checked the file had seen what the system generated me, not what the tablet dropped.

I apologize and appreciate everyone's support here.

    
asked by anonymous 12.08.2014 / 14:22

1 answer

0

I'll kick it, I do not know if it will solve.

The parse method also accepts a Reader as a parameter. Try to encapsulate the String in a StringReader and then parse:

JsonParser  parser = new JsonParser();

StringReader reader = new StringReader(json.getString("webservice"));

JsonElement elem   = parser.parse(reader);
JsonArray resultado2 = elem.getAsJsonArray();
int len = resultado2.size();
    
12.08.2014 / 14:59