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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:34:27+00:00 2026-06-05T08:34:27+00:00

I have to migrate the following code from Jackson 1.9 to 2.0 public class

  • 0

I have to migrate the following code from Jackson 1.9 to 2.0

public class ObjectIdDeserializer extends JsonDeserializer<ObjectId> {
    @Override
    public ObjectId deserialize(JsonParser jp, DeserializationContext context) {
        JsonNode oid = jp.readValueAsTree().get("$oid");
        return new ObjectId(oid.getTextValue());
    }
}

Because the return type of readValueAsTree() has change from JsonNode to TreeNode I’m not able anymore to access to its value. I’ve tried hasCurrentToken(), nextToken() and others strange methods like those without finding a way to access gracefully to the tree nodes. The get method that I was using rely on a map, so it does not need any iteration.

  • 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-05T08:34:29+00:00Added an answer on June 5, 2026 at 8:34 am

    According to ObjectMapper class from Jackson :

    public <T extends TreeNode> T readTree(JsonParser jp) throws IOException, JsonProcessingException
    {
        /* ... */
        JsonNode n = (JsonNode) _readValue(cfg, jp, JSON_NODE_TYPE);
        if (n == null) {
            n = getNodeFactory().nullNode();
        }
        @SuppressWarnings("unchecked")
        T result = (T) n;
        return result;
    }
    

    readTree method is called by readValueAsTree method, and as JsonNode implements TreeNode, just cast the TreeNode object returned to an JsonNode object and you’ll get the result that you expect !

    @Override
    public ObjectId deserialize(JsonParser jp, DeserializationContext context) {
        JsonNode oid = ((JsonNode)jp.readValueAsTree()).get("$oid");
        return new ObjectId(oid.asText());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to migrate a very large dataset from one system to another. One
I have already enabled scripts from Tools->Security->Custom... ...Please help migrate to proper forum/sub-site if
I am trying to migrate some code from using ElementTree to using lxml.etree and
I have a Code Composer project I received from a friend. When I try
I have the following bit of code in my htaccess that will allow a
I have been following documents on how to move from Rails 3 to 3.1
I have been asked to migrate some code to our new asp.net web app.
I currently have a tagging system in place with the following code rails g
I have to migrate a web application I made with ASP.NET MVC to a
I have got a blog in wordpress (www.ashwinm.com) which i am looking to migrate

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.