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 8467717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:43:29+00:00 2026-06-10T15:43:29+00:00

I have a lot of JSON data which is organized in nested lists. Each

  • 0

I have a lot of JSON data which is organized in nested lists. Each list consists of other lists and those lists could contain other lists and so on. The deepest list consists of a pair of longitute and latitude, e.g.

[[[…..[16.353542354,48.2354242424],[16.46353535,48.2546754646]….]…..].

It would look as graph like this:

Coord list

I basically don’t know how nested those lists are. They differ all the time. The next difficult part is that I need to get “coordinate polygons” from it. That means that the lists that only consist of pairs of coordinates belong to the same polygon. For example:

[……[[16.23542424,48.2342424242],[16.2423242352354,48.12342534634],[16.35353453535,48.345635353]]……

This would mean that there is a polygon consisting of 3 pairs of coordinates (so 3 corners).
I’m sure that this is solvable with some kind of String parsing. I wonder if this is possible with basic JSON.simple (or maybe any other API) possibilities. The problem is that JSON doesn’t know anything about the data it is parsing. I have to tell JSON what the object is and have to use type conversion to get the correct data. See these examples here. Now I need the other way around, but I never know what type is the data (“is it still another list or is the data the pair of coordiantes”), because those lists are very dynamic. How can this be done in a convenient way? I could write some string parsing algorithm with some “push and pop behavior” to compare the JSON string character by character, but I wonder if there isn’t a better way to do this?

[UPDATE]
I figured out that this is a standardized JSON format, called GeoJSON. If you know how to read the data, it’s pretty clear. A Multipolygon consists of Polygons, and Polygons can have holes, represented by a 2nd Array in a Polygon object. See spec:
Polygon, Multipolygon

  • 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-10T15:43:30+00:00Added an answer on June 10, 2026 at 3:43 pm

    I basically don’t know how nested those lists are

    You know exactly how deeply nested these lists are. At the top of your json, you have:

    "type": "Multipolygon"
    

    To me, that implies List<Polygon>. Now, what’s a Polygon? Well, that’s obviously a List<Coordinate>. Finally, we know a Coordinate is a list with two elements.

    To conclude, we have List<List<List<double>>>. The depth of the arrays is known.

    class Location {
        private double _lat;
        private double _long;
    
        public Location(double lat, double long) { _lat = lat; _long = long }
    
        public static Location fromJSONArray(JSONArray json) {
            int n = json.length();
            if(n != 2) throw new IllegalArgumentException('json');
    
            return new Location(json.getDouble(0), json.getDouble(1));
        }
    }
    class Polygon : List<Location> {
        public static Polygon fromJSONArray(JSONArray json) {
            int n = json.length();
            Polygon p = new Polygon();
            for(int i = 0; i < n; i++) {
                p.add(Location.fromJSONArray(json.getJSONArray(i)));
            }
            return polygon;
        }
    }
    
    private List<Polygon> parseLists(JSONArray nestedList) throws JSONException
    {
        List<Polygon> polygons = new ArrayList<Polygon>();
        int n = json.length();
        for(int i = 0; i < n; i++) {
            polygons.add(Polygon.fromJSONArray(json.getJSONArray(i)));
        }
        return polygons;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a Railo app which deals with a lot of JSON data
I have the following code which retrieves data with a JSON request: // Replace
I want to deserialize a JSON string which does not necessarily contain data for
I have a large JSON file that contains A LOT of similar code. It's
I have lot of code in my Tornado app which looks like this: @tornado.web.asynchronous
At the moment, I have lot's of Java which does all kind of nifty
I am creating Excel file download using NOPI libraries. I have lot of data
I am trying to build a data mart. I have lot of dimensions, and
I have some JSON which looks generally like this... {appJSON: [ { title:Application Title,
I have MySQL database, where I store the following BLOB (which contains JSON object)

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.