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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:49:48+00:00 2026-06-06T23:49:48+00:00

I have a problem creating a mapping for a json that i want to

  • 0

I have a problem creating a mapping for a json that i want to parse using json. It’s very specific, its about a json file with a json array with objects in it.

my jsonfile starts like this:

  [
    {
        "venue": {
            "venue_seasons": [
                {
                    "created_at": "2011-12-25T23:00:28Z",
                    "updated_at": "2011-12-28T15:13:53Z",
                    "start_timestamp": 1293840000,
                    "id": 337,
                    "end": "2011-12-24T00:00:00Z",
                    "enabled": true,
                    "start": "2011-01-01T00:00:00Z",
                    "season_openings": [ … ],
                    "end_timestamp": 1324684800
                },
                { … }
            ],
            "address": "someadress",
            "city": "cityname",
            "name": "name",
            "created_at": "2011-03-31T07:55:33Z",
        etcetera
    }
    "venue":{another venue

So first an array, than an object (venue) with a lot of objects in it (i removed most of them, because thats not important for my question), and some arrays (like season_openings).

My parsing code works like this, im using gson. The inputstream works fine.

Reader reader = new InputStreamReader(inputStream);
JsonResponse venueResponse = gson.fromJson(reader, JsonResponse.class);               
List<Venues> results = venueResponse.venue;

with the class JsonResponse:

public class JsonResponse {
    public List<Venues> venue;  
}

and Venues.class:

public class Venues {

    public List<VenueSeasons> venue_seasons;

    @SerializedName("adress")
    public String getAdress;

    @SerializedName("city")
    public String getCity;

    @SerializedName("country")
    public String getCountry; etcetera 
}

But when i run this code i get an error:

Unable to start activity ComponentInfo{com.hera.android.JSON/com.hera.android.JSON.TestParser2Activity}: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 2

Ofcourse i can read the error: it expects an objects but get an array. I varied a lot with different jsonresponse.class and even with putting the whole json array in a json object (what is not really a solution because i need to work with this type of jsonfile). But everytime i get this or a similar error.

I think I’m close to a solution, can anyone see what i just can’t and give me a helping hand?
Thanks.

  • 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-06T23:49:49+00:00Added an answer on June 6, 2026 at 11:49 pm

    Try calling Gson like this:

    List<Venues> venues = gson.fromJson(reader, new TypeToken<List<Venues>>() {}.getType());
    

    This works because your JSON document is a List, not an object that has a list as one of its properties.

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

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem with creating a simple MySQL trigger in C#. I'm using StringBuilder
I have a problem creating the following SQL Statement using LINQ & C# select
I have a problem creating and executing a JAR file. I have already made
I have encountered a problem with creating a thumbnail from an uploaded image file,
We have a problem creating photo album in facebook using android and graph API.
I have a problem creating a TIFF image with a JPEG compression using Magick++,
I have a problem creating a std::map<int, int> from a vector of pointers, called
I have the following problem: I am creating a simple plugin jquery carousel, to
I am creating an insert process in php but I have a problem in

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.