2
I am receiving a JSON file from a Webservice, this file comes with the approximate size of 5.7M, ai ai quando eu converter seu conteúdo para Jsonarray usando a biblioteca Gson, ele apresenta me o erro:
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 4045314
however the file is correct, when I file the same file with a slightly smaller amount of content (1.8M) to routine works normally, someone has knowledge of why this occurs, there is some known solution ?
Follows 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();
Guys, I’m sorry to everyone. I found the problem. The file was coming from corrupted not downloading completely, when I checked the file had seen what the system generated me, not what the tablet downloaded.
I apologize and I appreciate the support of everyone here.
Have you tried using this http://www.json.org/javalibrary/?
– Igor Ronner
Yes, it was the one I used before and gave a similar error, so I tried with gson because I saw that solved some cases.
– Hiago Souza
For performance I recommend the library
Jackson
, for Android has thejackson-jr
(https://github.com/FasterXML/jackson-jr).– Wakim
put the code you are using to convert. It can be optimized.
– Igor Ronner
Ready edited the question and put the code, @Wakim am reading about it now.
– Hiago Souza
Maybe it’s the case that you think about paging this file?
– OnoSendai
So I would also do the same Onosendai only that it is not mine the file comes from another system, and they can not do anything to paginate me the file because the service is used by other applications.
– Hiago Souza
@Hiagosouza Do you have at your disposal a server? One possibility would be to implement a parser there that will make the pagination for you.
– OnoSendai
So, the goal is to use the existing resource for the other applications, that is, the same server provides the information to the other applications, but if I need to allocate a server just to do this the project will become unviable ('expensive') for the final client. I’m trying to do the whole procedure on the tablet and to finish would just need to finish this part. He converting to the object I believe the rest of the routine will work normally. Note: I’m testing the Stringreader @Eduardo Oliveira sent. I want to give you an answer as soon as I’m done.
– Hiago Souza
There was no actual programming error.
– utluiz
No, there was no @utluiz.
– Hiago Souza