Parsing Huge JSON with Jackson

Consider a huge JSON with a structure like -

{"text": "very HUGE text here.."}

I save this JSON as an object ObjectNodecalled say json.

Now I am trying to extract this text from ObjectNode.

String text = json.get("text").asText()

This JSON can be 4-5 MB in size. When I run this code, I do not get the result (the program continues to run forever).

The above method works fine for small and normal size strings. Is there any other best practice for retrieving huge data from JSON?

+4
source share
2 answers

, : 5 UTF-8, 10 (char - 16 , UTF-8 - ). , JSON, Java String; . , Java , 64 : 10 , , , .

: . , .

+1

jackson (fastxml), 7MB json node 200

    ObjectMapper objectMapper = new ObjectMapper();
    InputStream is = getClass().getResourceAsStream("/test.json");
    long begin = System.currentTimeMillis();
    Map<String,String> obj = objectMapper.readValue(is, HashMap.class);
    long end = System.currentTimeMillis();
    System.out.println(obj.get("value").length() + "\t" + (end - begin));

: 7888888 168

?

+2

All Articles