The data represented as a JSON Map<String,ArrayList> is having trouble being converted into a bean object within Jersey's rest

Currently, I am facing an issue with retrieving Map values in my Ajax call with JSON data of String, Array and Map. While I am able to successfully get String and Array data by converting them into the Bean class DashboardChartData in Jersey, I am encountering difficulties in fetching Map values.

The code snippet is as follows:

function demo(){
var dashbord = {
"aoId": "M_AO_918",
"viewBys": ["Brand", "Category", "State"],
"viewIds": ["615228", "615128", "614847"],
"dimensions": ["615228"],
"aggregation": ["SUM", "SUM", "SUM", "SUM", "SUM", "SUM"],
"meassures": ["Gross Sales", "Net Sales", "Discount Amt", "Discount%", "Net Margin Amt", "Gross Margin Amt"],
"meassureIds": ["616275", "616283", "616279", "616648", "616295", "616303"],
"globalInFilters": {"615228": ["Lenovo", "Apple"]}
};

$("#query").html(JSON.stringify(dashbord));
$.ajax({
type: "POST",
contentType: "application/json; charSet=UTF-8",
dataType: "json",
data: JSON.stringify(dashbord),
url: "<%=request.getContextPath()%>/webresources/solrservice/test1",
success: function(data, textStatus, jqXHR){
alert('Bean created successfully');
},
error: function(jqXHR, textStatus, errorThrown){
alert('Bean error: ' + textStatus);
}
});
}    

I have defined the DashboardChartData class with the necessary parameters including:

private Map<String, List<String>> globalInFilters;

public Map<String, List<String>> getGlobalInFilters() {
return globalInFilters;
}

public void setGlobalInFilters(Map<String, List<String>> globalInFilters) {
this.globalInFilters = globalInFilters;
}


@Path("/test1")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void setData1(DashboardChartDataBean bean) throws Exception {
bean.getGlobalInFilters(); //getting null 
ProgenSolrDao daoObj = new ProgenSolrDao();

try {
QueryResponse response = daoObj.executeSolrQuery("city", bean);
} catch (Exception e) {

}

}

Despite all other values being fetched correctly, bean.getGlobalInFilters() returns null. I need assistance on how to retrieve the values of globalInFilters.

Answer №1

Have you considered sending it without stringifying first? It may be worth trying out.

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

What is the procedure for printing a list of categories and selecting each category individually in selenium/appium?

How do I print and click on a list of all items such as home top stories, latest news, opinion, etc. in each category, as shown in the image? I tried using the code below but didn't succeed. Can someone please help? List<WebElement> list=driver ...

Eliminate brackets from JSON string

Upon extracting a string from a JSON response: NSString *messageFromResponse = [NSString stringWithFormat:@"%@",[[JSON objectForKey:@"Response"]valueForKey:@"Message"]]; NSLog(@"<%@>", messageFromResponse); The extracted string appears as follows ...

Dealing with a missing response in an Ajax Server-Side Call: The .done(function(data){..} function remains inactive

Let's say I make an Ajax server-side call using jQuery like this: $.ajax({ url: "/myapp/fetchUser?username=" + username, type : "get", dataType : "json", data : '' }).done(function(data) { co ...

Creating a dictionary or JSON file to store print output

Incorporating boto3 for AWS, the code snippet below showcases how to utilize it: import boto3 from trp import Document # Document s3BucketName = "bucket" documentName = "doc.png" # Amazon Textract client textract = boto3.client('textract') # ...

Access a specific JSON value using AngularJS

When using AngularJS to read a specific JSON value, I encountered the following issue: $http({method: 'GET', url: urlVersion}). success(function(data, status, headers, config) { console.log("success data " + status); $scope.ext = data.ve ...

Having trouble converting a JSON array into a JavaScript array upon creation

I have encountered this question multiple times before and despite trying various solutions, I have not been able to find success. Summary: My goal is to retrieve the array from the classes.json file and then assign the data in the variable classes from d ...

Unable to insert a JSON object into an Array

This might appear to be a duplicate, but it's not. None of the solutions I've tried have worked. Within my angular module, I have a list: this.checkedInterviews = [] Followed by a function that does the following: var interviewModel = { ...

Best practice for setting response status and JSON content in a REST API built using nodejs and express

Exploring the world of Nodejs and express through creating a small rest API has led me to ponder on the best practices for setting the code status and response data. How should this be done effectively? To illustrate, let's delve into some code (I wi ...

Manipulating JSON with ng-model in AngularJS

Let's say I have a simple JSON similar to this: { "Object 0": {} } I am trying to display it as a tree structure. This is the approach I am taking: <span>{{key}}</span> // Object 0 <span>{{value}}</span> // {} <ul> ...

What is the best way to retrieve a response from a PHP file as an array through Ajax?

Seeking assistance in retrieving a complete address by entering the postal code in an HTML form textbox and clicking a button. The setup involves two files - one containing the ajax function and the other housing the PHP code. Uncertainty looms over whethe ...

What is the best way to store a collection of class instances in a serialized format

Is there a way to convert an object that contains a list of objects into JSON format? Error message received: TypeError: Object of type person is not JSON serializable Here's the code snippet in question: import json class person: def __init__( ...

Choosing an option from a selection dropdown using Protractor

Struggling to navigate through my Angular-built application using the regular Selenium webdriver. I've added ngwebdriver dependency in pom.xml to resolve some issues, but can't figure out how to handle a specific drop-down on a page. Here's ...

Easily create clickable words in Flutter by extracting specific words from a JSON String

In my JSON response, I receive a set of questions. My goal is to split these questions into words and compare them with another JSON response. When there's a match, I want to highlight the matching words and make them clickable to display a pop-up sho ...

Swift4 JSON Parsing Tool

Looking to convert a JSON file into a Codable struct in Swift4 for iOS11.1 and Xcode9.1, Below is my code: struct Station: Codable { let htmlAttributions: [String] let nextPageToken: String let status: String struct Result: Codable { ...

Is it possible for JSON deserialization to fail within a Controller action, yet succeed when performed explicitly?

Seeking clarification on a matter that has puzzled me. While my controller actions usually handle JSON deserialization to C# objects smoothly, there is currently an issue I am grappling with. Instead of producing the expected outcome, it presents a QBWebho ...

Implementing onClick functionality in RecyclerView post JSON data extraction

I recently implemented a RecyclerView in a fragment and successfully parsed JSON data from a website to display it in the RecyclerView following a helpful tutorial found at: Now, my next challenge is adding an onClick listener to the items in the Recycler ...

after ajax post, enhance original object by merging with the latest server values

After making a call to the server and successfully saving some data, I need to update the JSON array object that I have with new values. Here is a snippet of my code: [ { "id": 1, "uuid": "ce54acea-db20-4716-bceb-2f3deb1b2b86", "name": null, ...

Ways to access properties beyond the top-level object

I'm encountering issues with JSON parsing using the Jackson library { "userName": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5c7c9c4c7c9c4c7c9c4e5c2c8c4ccc98bc6cac8">[email protected]</a ...

Transforming JSON data into a CSV format

Dealing with a large JSON file containing multiple individual JSON objects, I am working on converting it to a CSV format where each row represents a combination of the outer id/name/alphabet in a JSON object and one set of conversion: id/name/alphabet. Th ...

Obtaining a list of child span elements using xpath in Selenium

I am looking to retrieve all child span elements based on the following xpath //label[@for='someText']/span Expected result: <span class="someClass">"Find this text"</span> <span id="someId">" ...