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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:19:46+00:00 2026-05-26T12:19:46+00:00

I have one ASP.NET Webservice that i calling from my Android app and getting

  • 0

I have one ASP.NET Webservice that i calling from my Android app and getting out a string with this JSON data:

{
    "d": [{
        "__type": "Trafikverket_API.Models.Trafiklage",
        "TagGrupp": "44be2cce-3055-4d22-aaf2-00e098b0422e",
        "Fran": "Gävle,Uppsala,Stockholm",
        "Till": "Norrköping,Linköping",
        "TrafikplatsNamn": "Nyköping C",
        "VisaAnkomst": "true",
        "InstalldAnkomst": "false",
        "InstalldAvgang": "false",
        "SparangivelseAvgang": "6",
        "AnmarkningarAvgang": "SJ Regional",
        "AnnonseratTagId": "249",
        "SparangivelseAnkomst": "6",
        "AnmarkningarAnkomst": "SJ Regional",
        "AnnonseradAnkomstTid": "21:50",
        "AnnonseradAvgangTid": "21:53",
        "BeraknadAvgangTid": null,
        "BeraknadAnkomstTid": null,
        "AnnonseradTidpunktAvgang": "2011-10-23T21:53:00+02:00"
    }, {
        "__type": "Trafikverket_API.Models.Trafiklage",
        "TagGrupp": "eae407a9-61ba-43f4-9c53-c666c2a3f117",
        "Fran": "Stockholm,Södertälje",
        "Till": "Norrköping,Linköping",
        "TrafikplatsNamn": "Nyköping C",
        "VisaAnkomst": "true",
        "InstalldAnkomst": "false",
        "InstalldAvgang": "false",
        "SparangivelseAvgang": "6",
        "AnmarkningarAvgang": "SJ Regional",
        "AnnonseratTagId": "251",
        "SparangivelseAnkomst": "6",
        "AnmarkningarAnkomst": "SJ Regional",
        "AnnonseradAnkomstTid": "22:52",
        "AnnonseradAvgangTid": "22:54",
        "BeraknadAvgangTid": null,
        "BeraknadAnkomstTid": null,
        "AnnonseradTidpunktAvgang": "2011-10-23T22:54:00+02:00"
    }, ..... ]
}

I have a object called StationInfo that looks like this:

public class DataModel 
{
    public Boolean VisaAnkomst;
    public String TagGrupp;
    public String Fran;
    public String Till;
    public String TrafikplatsNamn;
    public Boolean InstalldAnkomst;
    public Boolean InstalldAvgang;
    public String SparangivelseAvgang;
    public String AnmarkningarAvgang;
    public Integer AnnonseratTagId;
    public String SparangivelseAnkomst;
    public String AnmarkningarAnkomst;
    public String AnnonseradAnkomstTid;
    public String AnnonseradAvgangTid;
    public String BeraknadTidpunktAnkomst;
    public String BeraknadTidpunktAvgang;
    public String VerkligAnkomstTid;
    public String VerkligAvgangTid;
    public String BeraknadAvgangTid;
    public String BeraknadAnkomstTid;
    public String AnnonseradTidpunktAvgang;
    public String VerkligTidpunktAnkomst;
}

When i running this:

Gson gson = new Gson();
DataModel[] stationInfos = gson.fromJson(result, DataModel[].class);

I getting this exception:

com.google.gson.JsonParseException: Expecting object but found array

I ges i need some object that match the object “d” but how do i do that?

  • 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-05-26T12:19:46+00:00Added an answer on May 26, 2026 at 12:19 pm

    Instead of using Gson, i would suggest you to implement the in-built JSON classes:

    JSONObject obj;
    try {
        obj = new JSONObject("yourJsonData");
        JSONArray objD = obj.getJSONArray("d");  // getting your "d" array from json data           
        JSONObject subObject;
    
        for(int i=0; i<objD.length(); i++)
        {
            subObject = objD.getJSONObject(i); // getting one by one objects from Array
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my iPhone app that calls an ASP.NET Webservice to download data. Most
(sorry for the english) I have a ASP .net webservice that get data from
We have a legacy WSE3 ASP.Net webservice here that defines a method GetFileContent(string fileName)
Interesting one here. I have an ASP.NET 1.1 project that contains a web service
Using web forms I know that you can only have one ASP.NET form on
I'm doing an asp.net application with one page. In this page, I have one
This question is regarding the ASP.NET webservice that i am creating using the DAL-BLL
I have an asp.net .asmx webservice written to handle requests from a third party
I have a WCF webservice that acts as a data provider for my ASP.NET
I have a webservice that I am testing. When I use the personal asp.net

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.