2

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)

Planck Constant
  • 1,406
  • 1
  • 17
  • 19
  • 1
    Not sure on the technical details here, but regardless of "memory not being an issue", you're probably doing something wrong: if you're persisting objects using JSON, consider using an ad-hoc framework such as MongoDB (and probably modifying your data structures anyway). If this is an actual 5GB payload sent over a network, consider paging it. Also bottomline, there are plenty of specialized tools to monitor memory and performance. – Mena Jan 11 '17 at 15:53
  • Have you tried it? – M Platvoet Jan 11 '17 at 15:54
  • @Mena I know that "memory thing" sounds bad it is not my decision:( I will think about MongoDB – Planck Constant Jan 11 '17 at 16:20
  • @MPlatvoet I can try but the problem is that I don't know maximum size of my Json. Maybe it will work with 5GB and crash with 10GB. That's why I'm asking about the limits – Planck Constant Jan 11 '17 at 16:21
  • Wouldn't this question be better asked of the library's developers? – miken32 Jan 11 '17 at 23:29

1 Answers1

7

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.

Community
  • 1
  • 1
Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724