Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:19:26+00:00 2026-06-05T11:19:26+00:00

I have a very large .json file on disk. I want to instantiate this

  • 0

I have a very large .json file on disk. I want to instantiate this as a Java object using the Jackson parser.

The file looks like this:

[ { "prop1": "some_value",
    "prop2": "some_other_value",
    "something_random": [
      // ... arbitrary list of objects containing key/value 
      //     pairs of differing amounts and types ...
    ]
  },
  // ... repated many times ...
  {
  }
]

Basically it’s a big array of objects and each object has two string properties that identify it, then another inner array of objects where each object is a random collection of properties and values which are mostly strings and ints, but may contain arrays as well.

Due to this object layout, there isn’t a set schema I can use to easily instantiate these objects. Using the org.json processor requires attempting to allocate a string for the entire file, which often fails due to its size. So I’d like to use the streaming parser, but I am completely unfamiliar with it.

What I want in the end is a Map where the String is the value of prop1 and SomeObject is something that holds the data for the whole object (top-level array entry). Perhaps just the JSON which can then be parsed later on when it is needed?

Anyway, ideas on how to go about writing the code for this are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:19:26+00:00Added an answer on June 5, 2026 at 11:19 am

    Since you do not want to bind the whole thing as single object, you probably want to use readValues() method of ObjectReader. And if structure of individual values is kind of generic, you may want to bind them either as java.util.Maps or JsonNodes (Jackson’s tree model). So you would do something like:

    ObjectMapper mapper = new ObjectMapper();
    ObjectReader reader = mapper.reader(Map.class); // or JsonNode.class
    MappingIterator<Map> it = reader.readValues(new File("stuff.json"));
    while (it.hasNextValue()) {
       Map m = it.nextValue();
       // do something; like determine real type to use and:
       OtherType value = mapper.convertValue(OtherType.class);
    }
    

    to iterate over the whole thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I will have a possibly very large JSON file and I want to stream
I have two test cases using a reasonably large json object (1.2mb): source: data
I have a very large Excel sheet converted from a 6000 page PDF file,
I have a very large UIView approx 3000x3000 in size. In this large view
I have a very large data file with around 60000 rows. I need to
I have a very large XML file which has like 40000 data, and when
I need to pre-compress some very large html/xml/json files (large data dumps) using either
I have a large XML file (converted to JSON) that consists of multiple repeating
i am using the javascript simile timeline have a timeline items with very large
So, I have a file with a large JSON array of objects, and unfortunately,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.