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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:44:14+00:00 2026-05-26T17:44:14+00:00

http://pastebin.com/rXbeKqAa Hi all I have been trying to parse the above JSON into a

  • 0

http://pastebin.com/rXbeKqAa

Hi all I have been trying to parse the above JSON into a java program and store it into an object… (Don’t have a specific structure at the moment, as long as I can get the data from the object.)

Have been trying to use GSON but I can’t seem to get it right..

        String inputLine="";
    HttpClient httpclient= new DefaultHttpClient();
    HttpGet method = new HttpGet("http://localhost:3000/specs/215/errors.js");
    HttpResponse response =httpclient.execute(method);
    BufferedReader in = new BufferedReader(
            new InputStreamReader(
                    response.getEntity().getContent()));

    inputLine = in.readLine();
    System.out.println(inputLine);
    in.close();
    Gson gson = new Gson();
    JsonParser parser = new JsonParser();
    JsonArray array = parser.parse(inputLine).getAsJsonArray();

    for(int i=0; i < array.size(); i++) {

        Errors e = gson.fromJson(array.get(0), Errors.class);
        System.out.println(e.error.getReason());
    }

and the error i get is:

Exception in thread "main" java.lang.IllegalStateException: This is not a JSON Array.
    at com.google.gson.JsonElement.getAsJsonArray(JsonElement.java:99)
    at test.Getter.main(Getter.java:37)

Anyone please point me in the right direction?
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-05-26T17:44:15+00:00Added an answer on May 26, 2026 at 5:44 pm

    The JSON String is not a JSON Array String. JSON String starts and ends with {, } respectively while JSON Array starts and ends with [, ] respectively.

    This line is wrong:

    JsonArray array = parser.parse(inputLine).getAsJsonArray();
    

    Rather retrieve it as a JsonObject.

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

Sidebar

Related Questions

http://pastebin.com/AreCLL5W Could anyone help me with this, I've been trying all day to get
I am trying to learn Flex and now i have the next code: http://pastebin.com/rZwxF7w1
First of all, here's the full source code: http://pastebin.com/5teGNrPC *> IDENTIFICATION DIVISION. PROGRAM-ID. CAddress.
Here's an example program showing what I'm trying to do: http://pastebin.com/m1de1f3ba The XML in
I have the following code: http://pastebin.com/U9qYSmET When I try to telnet into my server
There are two JSON var (JSON.parse'd already) var acc http://pastebin.com/7DyfFzTx var sit http://pastebin.com/vnZiVaDx My
http://pastebin.com/Aa5rJxv8 i have django problem above, i tried to explain i need to show
Flex your RCurl/XML muscle. Shortest code wins. Parse into R: http://pastebin.com/CDzYXNbG Data should be:
When I run my program core.py ( http://pastebin.com/kbzbBUYd ) it returns: File core.py, line
I have a file with the structure like so: http://gamedev.pastebin.com/8iESYTVY but it's much bigger

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.