Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum size of Json handled by Jackson

Tags:

java

json

jackson

Is there a limit to the size of JSON file which can be handled by Jackson? My JSON can be huge. Simple example:

{
  "people": [
    {
      "Name": "John Smith",
      "number": "123-456-789"
    },
    {MILIONS OF OTHER PEOPLES}
  ],
  "cars": [MILIONS OF CARS],
  "dogs": [MILIONS OF DOGS],
  MORE HERE
}

It can be 5GB or more. I have to create it by using Jackson and send by network to another system. Memory is not a problem but what about Jackson? Can it write/read it without any problems?

Edit: I don't think it is a duplicate. I'm not asking how to parse huge Json files but what are the limits of Json/Jackson (if any)

like image 227
Planck Constant Avatar asked Sep 18 '25 03:09

Planck Constant


1 Answers

Jackson's ObjectMapper has a bunch of methods for reading JSON.

If you use the ones that take a byte[] or a String, then you're obviously restricted by the implicit limits of those types.

If you use the ones that take a File, an InputStream, or a Reader, depending on their underlying implementation, you can stream the whole thing and never hold the entire content of the file in memory at a given moment.

However, the ObjectMapper has to construct the entire object tree before returning it to your caller. It will need whatever amount of memory is required to build the objects in that tree.

Jackson imposes no hard limits itself.

like image 55
Sotirios Delimanolis Avatar answered Sep 19 '25 18:09

Sotirios Delimanolis