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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:28:15+00:00 2026-06-15T06:28:15+00:00

I have a JSON: { firstField: Something One, secondField: Something Two, thirdField: [ {

  • 0

I have a JSON:

{
    "firstField": "Something One",
    "secondField": "Something Two",
    "thirdField": [
        {
            "thirdField_one": "Something Four",
            "thirdField_two": "Something Five"
        },
        {
            "thirdField_one": "Something Six",
            "thirdField_two": "Something Seven"
        }
    ],
    "fifthField": [
        {
            "fifthField_one": "Something… ",
            "fifthField_two": "Something...",
            "fifthField_three": 12345
        },
        {
            "fifthField_one": "Something",
            "fifthField_two": "Something",
            "fifthField_three": 12345
        }
    ]
}

I have my classes:

public static class MyClass {
        @JsonProperty
        private String firstField, secondField;
        @JsonProperty
        private ThirdField thirdField;
        @JsonProperty
        private FifthField fifthField;

        public static class ThirdField {
            private List<ThirdFieldItem> thirdField;
        }

        public static class ThirdFieldItem {
            private String thirdField_one, thirdField_two;
        }

        public static class FifthField {
            private List<FifthFieldItem> fifthField;
        }

        public static class FifthFieldItem {
            private String fifthField_one, fifthField_two;
            private int fifthField_three;
        }
    }

I’m deserializing them with Jackson library:

public void testJackson() throws IOException {
    JsonFactory factory = new JsonFactory();
    ObjectMapper mapper = new ObjectMapper(factory);
    File from = new File("text.txt"); // JSON I mentioned above
    mapper.readValue(from, MyClass.class);
}

but I’m getting the Exception:

org.codehaus.jackson.map.JsonMappingException: Can not deserialize
instance of Main$MyClass$ThirdField out of START_ARRAY token

  • 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-15T06:28:16+00:00Added an answer on June 15, 2026 at 6:28 am

    You defined your thirdField and fifthField properties as arrays in your JSON. They need to be arrays or collections on your Java bean as well:

    public static class MyClass {
        @JsonProperty
        private String firstField, secondField;
    
        @JsonProperty
        private Collection<ThirdField> thirdField;
    
        @JsonProperty
        private Collection<FifthField> fifthField;
    
        /// ...
    }
    

    As you are going through and converting an existing JSON object into beans, keep in mind that JSON data is very much like a map. If you envision how you would map the data from a map into your object it really helps. Your ThirdField and FifthField objects need to map the definitions in your JSON. This is what your JSON says a ThirdField is:

    {
        "thirdField_one": "Something Four",
        "thirdField_two": "Something Five"
    }
    

    Literally converting that to a Java bean gives you:

    public class ThirdField implements Serializable {
        private String thirdField_one;
        private String thirdField_two;
    
        // ...
    }
    

    You can add in your annotations etc, etc to get a full fledged bean. Do the same thing for your FifthField object.

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

Sidebar

Related Questions

I have JSON like this: { something: http://something.com } and HTML like this: <a
I have JSON data like this [ 00-00-02:first one, 00-00-04:the second, 00-00-09:third, . .
I have json array like this one: [{code : A1, desc : desc1},{code :
Using Jackson, how can I have JSON serialized/deserialized by one application using one set
I have JSON Object that looks something like the below object, this object can
I have json with field that contains two different types. fields:[{value:ZIELONE OKO},{value:{@nil:true}}] I have
I have JSON Response Request and want make one variable $Where from them, this
I have JSON array with one object consisting of nodes and links. data =
i have JSON data from php -it's one dimensional array-: {pair:[-8.5745000,115.3735700,-8.5683300,115.3733700,-8.5683300,115.3733700,-8.5687800,115.3997700,-8.5687800,115.3997700,-8.5764900,115.4007400,-8.5764900,115.4007400,-8.5687800,115.3997700,-8.5687800,115.3997700,-8.5656400,115.4156400,-8.5656400,115.4156400,-8.5565200,115.4122800,-8.5565200,115.4122800,-8.5566200,115.4110500,-8.5566200,115.4110500,-8.5560700,115.4112200,-8.5560700,115.4112200,-8.5554200,115.4112800,-8.5554200,115.4112800,-8.5527200,115.4025400,-8.5527200,115.4025400,-8.5424000,115.4027000,-8.5424000,115.4027000,-8.5426600,115.4055800,-8.5426600,115.4055800,-8.5377000,115.4057200,-8.5377000,115.4057200,-8.5375900,115.4034500,-8.5375900,115.4034500,-8.5358900,115.4036500,-8.5358900,115.4036500,-8.5358800,115.4033400]} and in android
I have JSON string that has nested objects with dynamic names that vary each

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.