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

  • Home
  • SEARCH
  • 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 9161399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:57:32+00:00 2026-06-17T13:57:32+00:00

I have an object called Route which stores an ArrayList of RouteStep objects. A

  • 0

I have an object called Route which stores an ArrayList of RouteStep objects.

A RouteStep object stores and ArrayList of int[].

Here is a sample of the classes. They contain other fields but I have omitted them here:

public class Route {

    @Expose private long routeId;
    @Expose private List<RouteStep> routeSteps;

    public Route() {}

    public long getRouteId() {
        return routeId;
    }

    public void setRouteId(long routeId) {
        this.routeId = routeId;
    }


    public List<RouteStep> getRouteSteps() {
        return routeSteps;
    }

    public void setRouteSteps(List<RouteStep> routeSteps) {
        this.routeSteps = routeSteps;
    }
}

public class RouteStep {

    @Expose private ArrayList<int[]> coordinates = new ArrayList<int[]>();

    public RouteStep() {}

    public ArrayList<int[]> getCoordinates() {
        return coordinates;
    }

    public void setCoordinates(ArrayList<int[]> coordinates) {
        this.coordinates = coordinates;
    }       
}

Here is an example of the Json that needs to be parsed:

[
    {
        "routeId": -1,
        "user": "aa",
        "date": "08/01/2013 18:20:49",
        "routeName": "route 1",
        "distance": 536.4938,
        "routeSteps": [
            {
                "type": "LineString",
                "coordinates": [
                    [
                        55.940847,
                        -3.182992000000008
                    ],
                    [
                        55.941983999999984,
                        -3.186577000000001
                    ],
                    [
                        55.94265899999998,
                        -3.19088
                    ]
                ]
            }
        ]
    },
    {
        "routeId": -2,
        "user": "aa",
        "date": "08/01/2013 18:21:39",
        "routeName": "route 2",
        "distance": 455.127,
        "routeSteps": [
            {
                "type": "LineString",
                "coordinates": [
                    [
                        55.94265899999998,
                        -3.19088
                    ],
                    [
                        55.942732999999976,
                        -3.191536000000003
                    ],
                    [
                        55.94519300000003,
                        -3.19124800000001
                    ],
                    [
                        55.946433,
                        -3.191014999999997
                    ]
                ]
            }
        ]
    }
]

I have this in my class which is meant to parse the Json:

Gson gson = new Gson();

        try {
            routes = gson.fromJson(json, Route[].class);                
        } catch(JsonSyntaxException e1) {
            Log.e(TAG, "Syntax exception in retrieved JSON");
        } catch(JsonParseException e2) {
            Log.e(TAG, "Exception occured parsing retrieved JSON");
        }   

I keep getting JsonSyntaxExceptions when this runs. I have used the same code to parse arrays of objects that contain ArrayLists of primitive types such as int[] but I am not sure how to do it when the ArrayList contains objects of my own type.

  • 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-17T13:57:33+00:00Added an answer on June 17, 2026 at 1:57 pm

    Posting your actual stack trace would help but … you have:

    private ArrayList<int[]> coordinates = new ArrayList<int[]>();
    

    And are trying to parse:

    [
        55.940847,
        -3.182992000000008
    ],
    

    Those aren’t ints. Fix that and it should work fine.

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

Sidebar

Related Questions

I have an object called users that I use to store user objects that
Here is the scenario: I have an object called a Transaction that needs to
I have an object class called BOM. It has a method, getChildItem() which returns
I have a parent object called Page that has a List of objects called
I have an object called Layer that has some attributes and some methodes. i
I have an object called Document that has a one-to-many relationship with DocumentPersonCc. I
I have a object called: SqlCeDataReader rdr; Because SqlCeDataReader does not have HasRows function,
I have an object called Contact. A Contact has a relationship with a set
I'm having an issue with an if statement I have an object called enemy2
I have an NSDate object called 'dueDate'. I'm trying to work out how to

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.