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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:05:48+00:00 2026-05-25T18:05:48+00:00

For parsing JSON like this twitter API users/show response I’ve been using Jackson and

  • 0

For parsing JSON like this twitter API users/show response I’ve been using Jackson and Gson Java libraries as candidates to do this work. I’m only interested in a small subset of properties of the JSON so Gson was nice because of its very concise syntax but I’m losing an internal battle to continue to use Gson as Jackson is already used elsewhere in our application and it has documented better performance (which I concede are both good reasons to lose Gson).

For a POJO like

public class TwitterUser {
private String id_str;
private String screen_name;

public String getId_str() {
    return id_str;
}

public void setId_str(String id_str) {
    this.id_str = id_str;
}

public String getScreen_name() {
    return screen_name;
}

public void setScreen_name(String screen_name) {
    this.screen_name = screen_name;
}
}

The only code for Gson needed to build this is one line,

TwitterUser user = new Gson().fromJson(jsonStr, TwitterUser.class);

That’s pretty nice to me; scales well and is opt-in for the properties you want. Jackson on the other hand is a little more laborious for building a POJO from selected fields.

Map<String,Object> userData = new ObjectMapper().readValue(jsonStr, Map.class);
//then build TwitterUser manually

or

TwitterUser user = new ObjectMapper().readValue(jsonStr, TwitterUser.class);
//each unused property must be marked as ignorable. Yikes! For 30 odd ignored fields thats too much configuration.

So after that long winded explanation, is there a way I can use Jackson with less code than is demonstrated above?

  • 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-25T18:05:49+00:00Added an answer on May 25, 2026 at 6:05 pm

    With Jackson 1.4+ you can use the class-level @JsonIgnoreProperties annotation to silently ignore unknown fields, with ignoreUnknown set to true.

    @JsonIgnoreProperties(ignoreUnknown = true)
    public class TwitterUser {
        // snip...
    }
    
    • http://wiki.fasterxml.com/JacksonAnnotations
    • http://wiki.fasterxml.com/JacksonHowToIgnoreUnknown
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing a JSON object (from YQL) that includes some null values, like this:
So I'm parsing data from twitter api in rails using the twitter library, and
I'm manually parsing Json objects using java and I have a problem with urls.
I'm parsing JSON that looks like this: { attr1: true, attr2: foo, attr3: 7,
I found this article about parsing JSON response from a URL request i iOS:
i try to parsing json with format like this { bossresponse:{ responsecode:200, web:{ start:0,
I'm parsing a JSON response via $.ajax() and building a form from this object's
I am parsing a json string like so: ring = JSON.parse(response); Now, ring is
I'm parsing a json feed routinely and need to insert only the newest users
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() 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.