Good day, I am interested in the question: Minimizing memory consumption when receiving and parsing data ( JSON ) , that is, not fully downloaded because I do not want to get "The application is not responding . " Thanks in advance

  • What are you working on? - teran
  • so that the “application does not respond” (win-application?) run the parser in a separate thread, but again depends on the implementation technology. - teran
  • I am developing for android, in AndrStudio. In AsinkTask, I launch the parser, but it turns out that the parsing takes almost all of the allocated resources to the application - v.podlipnyak

2 answers 2

Until the entire string is received, the parser will not parse the part.
For example, {data... 100000 символов ... } . Without the last bracket, you can’t get it right.

It is solved simply - not to send it right away, but in parts.

  • that way and there are no SAX parsers for XML? - teran
  • @teran, there is, but not json . - user207618
  • Something here (the first link from Google) will not particularly agree with you, but no one bothers to implement such a parser yourself. - teran
  • OK, there is. I do not know how much this can be considered what is expected in the question, but let it be. Answer about SAX. - user207618
  • Okay thank you. And how to parsit parts, through third-party library? - v.podlipnyak

Not every 6 mb json ʻa occupy equally large / small amount of resources. The important role is played by which objects of the language the original json is transformed, and which parser is engaged in parsing. If you parse on your own, then you are most likely invented the bicycle - there are already many libraries with an optimized parsing algorithm.

  • and where did java come from? - teran
  • Oh, read the json label as java. Corrected, but essentially it does not change. - AseN