Skip to content
Advertisement

Tag: json

How to process object with map for CSV output

I have a set of below Objects, which i need to write to CSV: Above set can have a map with two, three or four values. Output of CSV required: I started with below snippet to print out: But above is creating a two column csv with userId and behaviours printing all map object behaviours. How to achieve above type

How to avoid Jackson escaping double quotes in Java?

I am working on a project and wanted to rewrite some code written in Gson to Jackson using ObjectMapper. So I am trying to create a JSON string using some properties as below: Expected result: Actual: So once I create a JSON String using Jackson, it turns out it is escaping double quotes for field names and values and adding

Java JSON String problem encoding Multipart

I’m developing a REST API that receives a MultipartFormDataInput object (org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput), this comes from a form-data Vue.js app. On the data field comes a json string that contains latin accent characters (á, é, í, ó, ú, ñ). When print the json data in Java I get this: Original Json string Json string received in Java What can i do to

Is OpenAPI v.3 incomplete or convertor is wrong?

I am trying to validate some data for the REST API using swagger description. I have converted swagger.json into OpenAPI 3.0.1 using swagger editor conversion option, and now trying to read it into OpenAPI object with ObjectMapper with following lines of code: First, I got an error as it could not recognized the field x-codegen-request-body-name generated by the converter. Fine,

GSON – trim string during deserialization from JSON

I have a JSON string that is parsed using the GSON library into a Map like so: The problem I have is, my JSON attribute values have trailing/leading whitespaces that needs to be trimmed. Ideally, I want this to be done when the data is parsed to the Map using GSON. Is something like this possible? Answer You need to

Mapping nested JSON values in a Java class

I can’t figure out how to handle nested JSON values in my Java classes. To make it simple as possible, I created four Java classes with every ‘nested level’. However, I’m trying to have all these values in one Java class. How can I do this? Json: Java classes: Answer You can club all the supporting classes in one class

Serializing JSON with class metadata

I’ve used both Gson and Jackson and both of them offer a way to deal with polymorphism. For example, with Jackson you need to declare the class with a @JsonSubTypes and add each and every @JsonSubTypes.Type you have. Similar thing happens with Gson. My question is if there is an option to make it work like with how MongoDB serializes

How to generated the csv file from json data with Java?

I try to generate csv file from json type data. These are my json test data. The problem is json array type “seriess” does not contain “notes” node in all every nodes. I made the below java codes to change this json data to csv file with header columns But the incorrect results are shown like below, The generated header

Why are related entities being escaped when converted to JSON?

I have a Spring MVC controller which fetches some entities via a query. These entities have a related entity that is eagerly fetched. However, when I use JSONObject.toString() it escapes the related model data: The value in the language property is an escaped JSON object from the related entity. Why is it being escaped like that? How do I prevent

Advertisement