Unable to convert the array token into an instance of the model class

I'm currently attempting to send a JSON array list to a Spring REST endpoint and implementing my logic as shown below:

Model Class :

public class ABCDEF{

private String A;
private String B;
private ArrayList<Long> C;
private ArrayList<Long> D;
private ArrayList<String> E;
private String F;

//getter //setter
}

Rest call :

@RequestMapping(value="/post/data", method = RequestMethod.POST,consumes = "application/json", produces = "application/json")
public List<ModelClass1> retrieveData(@RequestBody List<ABCDEF> dataFromUser){

return null;

}

Input attempted :

[
{
"A" : "something",    
"B":"something",   
"C":[1],
"D": [1,2],
"E":["123","1234"],
"F":"something"
},
{
"A" : "something",    
"B":"something",   
"C":[4,5],
"D": [7,8,9],
"E":["1111","9999"],
"F":"something"
}
]

However, it is throwing an exception:

nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.ABCDEF out of START_ARRAY token

Can someone provide insight into where I may be making a mistake?

Answer №1

One solution is to utilize the jackson-databind jar.

If you have already tried this approach after encountering the exception, check out this link, which states that the issue was resolved in Spring 3.2.

For additional guidance, take a look at this resource.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Failed to retrieve JSON data due to key access error

Below is the JSON data that I am working with: Merchant_stripe_response Object ( [_response:protected] => stdClass Object ( [object] => customer [created] => 1387883058 [id] => cus_3BFTkHufSbD1I9 ...

code reading json without specified key

I'm facing what seems like a simple question, but I can't seem to crack the code. I'm currently coding in Python 3.3 and have retrieved something from a JSON file that resembles this: some_list = json_response['key'] # some_list ...

Node.js/Hapijs - Verify every property and value in JSON object payload without explicitly naming the properties

One of the challenges I'm facing with my API is handling POST-sent payload input that needs to be passed on to another application for processing. The input is always in JSON format, and the values must strictly be numeric. With hundreds of different ...

Removing unnecessary keys from intricate JSON data (with the use of pure JavaScript)

I've experimented with various methods to dynamically parse and remove keys with empty values from a JSON file using JavaScript. Currently, I can successfully delete non-nested keys, except for empty strings that have a length greater than 0. My mai ...

Convert JSON data into a nested unordered list

I need help converting a JSON object into an unordered list using jQuery. Here's the JSON data I have: var myJSON = "{name:\"Director\",children:[name:\"Exe Director1\",name:\"Exe Director2\",name:\"Exe Director3&bs ...

Is there a more effective way to write and enhance the custom Json string format?

In Python 2.7, I'm constructing a json string (result of an api call) that includes a list of unanswered threads. Currently, each thread is represented as an array element, and this setup has been functioning smoothly for me. However, in my quest to e ...

Guide to creating a dynamic form using Phonegap and jQuery Mobile

Currently, I am working on an iPhone and Android app using Phonegap and jQueryMobile. The app receives a JSON with a form that was generated by my ruby on rails web application. However, I have encountered a significant issue. The form is quite large, con ...

Attempting to retrieve JSON data and present it in a grid layout

I have a JSON file with the following data: { "rooms":[ { "id": "1", "name": "living", "Description": "The living room", "backgroundpath":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSrsU8tuZWySrSuRYdz7 ...

Reading a file in pyspark that contains a mix of JSON and non-JSON columns

Currently, I am faced with the task of reading and converting a csv file that contains both json and non-json columns. After successfully reading the file and storing it in a dataframe, the schema appears as follows: root |-- 'id': string (null ...

Retrieving information from MongoDB

Currently, I am working on retrieving data from MongoDB and passing it to my Express server to eventually display it in my HTML using Angular. The retrieval process is successful when there is only one record in the database. However, if multiple records a ...

Transforming a tabular dataset into hierarchical JSON structure

import pandas as pd import numpy as np arrays = [ ["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"], ["one", "two", "one", "tw ...

"Encountered a problem while trying to insert data using JSON and Ajax

I've been struggling to figure out where the issue lies in my code. I've double-checked everything and it all seems correct, but I keep encountering errors. Below is the code snippet: Markup: <link href="http://ajax.googleapis.com/ajax/libs ...

Make sure to refresh the model using an Ajax request in Spring MVC

I have a page where I use AJAX to insert data into my database. On that same page, I display a table of records that are inserted. Each time I add a new record, I want to update the content of the table. Here is what I have implemented: @RequestMapping(va ...

Transferring information from JSON to HTML

Recently, I came across this handy design tool within our service that helps generate Gauge charts by simply adding a specific div class to the desired pages. <div class="gauge" id="g0" data-settings=' { "value": ...

Custom Jackson Deserialization to Map String Class Names to Class Definitions

Utilizing custom Jackson Deserializers for parsing a JSON file is my current task. Within this JSON file, there are numerous entries with the key "class" and values representing the class names (without the full package name). The deserializer has access t ...

The Struts2 JSON response received through the $.getJSON method is showing an unexpected undefined result

Attempting to retrieve a String value from an action class using the $.getJSON method, but receiving an output of undefined. Below are the code snippets that have been tested: Script: $(function() { $("#newPostionFormID").submit( ...

The error message encountered in Python is: "Cannot iterate over the '_csv.writer' object due to a TypeError."

I'm currently facing an error while parsing json to csv: for i in data: TypeError: '_csv.writer' object is not iterable Here is the code snippet: import json import csv with open("Data.json", 'r') as file: data = json.load( ...

Generating JSON output in PHP

I've been struggling to figure out why I can extract some parts of the JSON data but not others... Essentially, I am retrieving JSON from a URL (). In my PHP code (using Laravel5), I have the following: $url = 'https://public-crest.eveonline.co ...

What could be causing the select2 to not display the most up-to-date information in the control?

I have implemented a progressive search feature but it seems that the data returned is not populating the control properly. $("#selUser").select2({ ajax: { url: "/M01EngineeringData/GetFunctionalLocations", ty ...

Utilize JQuery AJAX to retrieve a PHP array and then store it in a JavaScript variable

I am facing a challenge that seems simple to resolve, but it's proving to be quite tricky. Currently, I have a functional PHP file that fetches data from a database and stores it in an array. This file does not require any parameters and the output i ...