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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:36:15+00:00 2026-05-27T08:36:15+00:00

I am trying to deserialize a JSON String like (extracted this bit to show

  • 0

I am trying to deserialize a JSON String like (extracted this bit to show the issue)

{
    "$type": "com.example.StringProperty",
    "value": "hello world",
    "name": "text",
    "readOnly": false
}

into a hierarchy of classes that look like

public class Property
{
    public String name;
    public int    type;

    Property(String pName, int pType) { name = pName; type = pType; }
}

public class StringProperty extends Property 
{
    public String value;        
    StringProperty(String pName, String pValue) {
        super(pName, String);
        value = pValue;
    }       
}

using the following mixin annotations

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="$type")
abstract public class PropertyMixin
{
    @JsonProperty
    public String name;
    //@JsonIgnore
    //public boolean readOnly;
    @JsonProperty
    public int type;

    PropertyMixin(@JsonProperty("name") String pName, @JsonProperty("type") int pType)
    {
    }
}

abstract public class StringPropertyMixin
{
    @JsonProperty
    public String value;
    //@JsonIgnore
    //public boolean readOnly;

    @JsonCreator
    public StringPropertyMixin(@JsonProperty("name") String pName, @JsonProperty("value") String value)
    {
    }
}

With Jackson 1.9.2, the error I am getting is

Unrecognized field "readOnly" (Class com.example.StringProperty), not marked as ignorable

I tried using @JsonIgnore, but that did not help (check the locations of the code I commented out to see how I tried it). I am probably missing something, but I think another set of eyes need to look at it and help me.

This is how the deserialization environment looks like:

        objectMapper.setVisibilityChecker(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
                .withFieldVisibility(JsonAutoDetect.Visibility.NONE)
                .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));

        MixinRegistrations module = new MixinRegistrations();
        objectMapper.registerModule(module);

and mixin module looks like

@Override
public void setupModule(SetupContext context)
{
    context.setMixInAnnotations(Property.class, PropertyMixin.class);
    context.setMixInAnnotations(StringProperty.class, StringPropertyMixin.class);
}

I appreciate all the help. Thanks in advance.

PS: I do not know if this makes a difference but the JSON is being generated by a library written in .Net Framework v4.

  • 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-27T08:36:15+00:00Added an answer on May 27, 2026 at 8:36 am

    I believe Jackson is having problems because the method that you have delegated as a creator does not have a parameter for the readOnly field. So rather than silently ignore this missing parameter Jackson is throwing an error (good behaviour). Try using the JsonIgnoreProperties annotation. I’ve not had need to use if before, but for deserialisation you can explicitly denote fields that are not required by the creator.

    Oh, this appears related as well.

    Edit:
    Another question that the asker found that was useful.

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

Sidebar

Related Questions

I am trying to deserialize a JSON string that looks like so: {'type':'clientlist','client_list':[]} I
I'm trying to deserialize a relative simple JSON string, which looks like: [{ FacebookID:
I am trying to deserialize this Json: [ { Address: String content, CategoryId: 2147483647,
I'm trying to deserialize an xml structure that looks like this: <somecontainer> <key1>Value1</key1> <key1>Value2</key1>
i'm trying to deserialize a json string pulled from the web using json.net, but
I am trying to deserialize a JSON string that was serialized by JSON.Net 4.0
Hi i am trying to parse Json using gson library.My Json String is this
I have a string of JSON like this: { letterstats:[ {time_taken:636,mistake_letters:,the_letter:L,success:true}, {time_taken:216,mistake_letters:,the_letter:U,success:true}, {time_taken:103,mistake_letters:,the_letter:I,success:true} ],
I'm trying to deserialize sample JSON at the end of this question with below.
Trying to deserialize this JSON: { result:success arguments: { activeTorrentCount:22, cumulative-stats: { downloadedBytes:1111, }

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.