com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

We Are Going To Discuss About com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token. So lets Start this Java Article.

com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

  1. com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

    You have mapped the RequestBody to a single User object but you are sending in JSON array.
    [{ "firstName": "hgf", "lastName": "frew", "username": "erf", "email": "bgghjk", "password": "bgte", "role": "trrere" } ]

  2. com.fasterxml.jackson.databind.exc.MismatchedInputException: Can not deserialize instance of object out of START_ARRAY token

    You have mapped the RequestBody to a single User object but you are sending in JSON array.
    [{ "firstName": "hgf", "lastName": "frew", "username": "erf", "email": "bgghjk", "password": "bgte", "role": "trrere" } ]

Solution 1

You have mapped the RequestBody to a single User object but you are sending in JSON array.

[{
    "firstName": "hgf",
    "lastName": "frew",
    "username": "erf",
    "email": "bgghjk",
    "password": "bgte",
    "role": "trrere"
  }
]

You should send a JSON object instead as follows

{
    "firstName": "hgf",
    "lastName": "frew",
    "username": "erf",
    "email": "bgghjk",
    "password": "bgte",
    "role": "trrere"
}

or change the controller mapping to receive a collection of User objects as

@RequestBody List<User> users

Original Author Master Po Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment