0

I am working on an old project written in Delphi. The server (Node.JS) processes requests from the client (Delphi Seattle) and returns the data from the database as JSON text. There's no problem in getting data on the client side, as soon as I want to process the data into TJSonObject to append them into the dataset later on. If I have approximately like 200k rows, I have an out of memory problem happens in this line of code:

JsonData := TJSONObject.ParseJSONValue(Response) as TJSONObject;

There's no such problems with small amount of data, but as soon as data gets large, it becomes very time consuming and falls with Out of Memory at some point.

Is there a fast and convenient way to parse JSON in Delphi?

  • Why would you want to serve 200K rows of data to the client? – Andy Jul 08 '21 at 19:55
  • Because the company needs a report for the investors from the day the company was created – Aharon Zilberman Jul 08 '21 at 19:58
  • `ParseJSONValue()` parses the input JSON into a tree of objects. If too much memory is being used to build that tree, then try using `TJSONIterator` instead. See the documentation for more details: [Readers and Writers JSON Framework](http://docwiki.embarcadero.com/RADStudio/en/Readers_and_Writers_JSON_Framework) – Remy Lebeau Jul 08 '21 at 20:12
  • Sorry, @ArkadyTkach, the point I was trying to make is that you should keep the data on the server/db and just have the client use an API to request only the data it needs, and let the server handle the heavy lifting. – Andy Jul 09 '21 at 10:04

0 Answers0