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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:30:10+00:00 2026-05-29T05:30:10+00:00

I am using the Jackson JSON parser as I heard it was a lot

  • 0

I am using the Jackson JSON parser as I heard it was a lot more efficient than the default Android parser. I learned how to use it off this tutorial here

http://www.mkyong.com/java/jackson-streaming-api-to-read-and-write-json/

which is great tutorial if anyone wants to learn how to use Jackson json parser.

However, I am having an issue in that I can parse data fine in Java from a URL, however when I use Jackson with Android, I get null values or the screen just shows up black for some reason.

In order to retrieve the data from the website I am using this code from here

http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html

  private InputStream retrieveStream(String url) {

    DefaultHttpClient client = new DefaultHttpClient(); 

    HttpGet getRequest = new HttpGet(url);

    try {

       HttpResponse getResponse = client.execute(getRequest);
       final int statusCode = getResponse.getStatusLine().getStatusCode();

       if (statusCode != HttpStatus.SC_OK) { 
          Log.w(getClass().getSimpleName(), 
              "Error " + statusCode + " for URL " + url); 
          return null;
       }

       HttpEntity getResponseEntity = getResponse.getEntity();
       return getResponseEntity.getContent();

    } 
    catch (IOException e) {
       getRequest.abort();
       Log.w(getClass().getSimpleName(), "Error for URL " + url, e);
    }

    return null;

 }

Then in my parse data method

        InputStream source = retrieveStream(url);

    try {

        JsonFactory jfactory = new JsonFactory();


        JsonParser jParser = jfactory.createJsonParser(source);

Then I parse data as was shown in the tutorial I linked above

    while (jParser.nextToken() != JsonToken.END_OBJECT) {

            String fieldname = jParser.getCurrentName();
            if ("Name".equals(fieldname)) {
                jParser.nextToken();
                this.setName(jParser.getText());
            }
            if ("Number".equals(fieldname)) {
                jParser.nextToken();
                this.setNumber(jParser.getText());
            }
        }

The url I am using is a dummy site set up which just has a JSON file on it which I am using to practice Jackson JSON parsing.

Now I know my parse data code is fine, as I in normal Java class, I can parse the data from the website using the code I created, and it works fine.

However if I try to use the code in Android with the code I have just shown, I just get a black screen for some odd reason. I have internet permissions enabled in manifest

Is there something wrong with the http code I have used? If so could someone show me how it should be done? And also why I am getting a black screen, I don’t understand why it would show that.

Thanks in advance

  • 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-29T05:30:10+00:00Added an answer on May 29, 2026 at 5:30 am

    I found the issue, the link was local host which could not be accessed from Emulator. Settings were changed, and can now access link, works perfectly now 😀

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

Sidebar

Related Questions

I'm trying to use Jackson to deserialize some JSON originally created using Jackson. The
I'm using the jackson library for serializing/deserializing to/from JSON. I need that this JSON
For parsing JSON like this twitter API users/show response I've been using Jackson and
Can I use Jackson instead of JSON-lib with Groovy's HTTPBuilder when setting the body
I am using Jackson and a ContentNegotiatingViewResolver to return JSON from Spring controllers. When
I am using spring android rest template and trying to convert a JSON response
I am a newbie to using jackson library. I am trying to do this
I implemented a RESTful web service with Spring and am using Jackson JSON as
I am using JSON Jackson to convert from POJOs to JSON. I am using
I've implemented a Spring RESTful web service. Using Jackson JSON for Object Mapping. I

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.