I’m testing an API and get all data from the DB. I save the response as I get a json as response. I want to get the length of json array. So, if I have 2 rows in DB, I want to get 2 as a result. Or is there maybe another way to count number of rows which are
Tag: json
Deserialize JSON date format to ZonedDateTime using objectMapper
Background I have the following JSON (message from Kafka) I have the following (JSON schema generated) POJO (I cannot change the POJO as it is shared resource in the company) Our application is a Spring Boot application which reads the JSON message (1) from Kafka using Spring Cloud Stream and uses the POJO (2…
Dynamically choosing which class to create object of from json
I have an interesting problem that I’m having trouble coming up with a clean solution for. My application reads collections of json objects that it needs to deserialize to this or that class type based on a field in the json itself. I have no control over the json structure or how it gets to my applicat…
JavaJSON: UnrecognizedPropertyException: Unrecognized field “CefMessagesGenerators” error
I have the following Json and corresponding Java classes. Could you please check it out and advise why do I get this exception? Is it because I added another and the (partial) json is: (Unfortunately I had to add the json image instead as text here because the system claims “I have the following Json an…
java.lang.NoSuchMethodError: org.json.JSONObject.(Ljava/lang/Object;)V
I have a basic SpringBoot 2.1.5.RELEASE app. Using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file with some RestControllers. In 1 of the controller this is the body I send: so I create this class to send it as a RequestBody: and public class Hotelswi…
How can I create the Table and insert the json data by using JAVA in CQL?
I am the new learner in CQL. I am using the docker env to run the Cassandra. In previous, I have the two tables(restaurants and Inspection) with inserted the data by csv and the following setting: Since join method are not supported in CQL, I need to re-insert the joined data set(JSON) to a new table(call Ins…
Unable to use custom HttpMessageNotReadableException error message in Spring Boot
I’m currently trying to provide custom messages for exceptions, but ran into an issue with HttpMessageNotReadableException. I have an ErrorDetails class: I also have a custom exception handler: But when i try to post a bad request, for example, with a field that should have a integer value I pass a stri…
Getting null values while mapping a JSON to POJO
I am trying to map a JSON to POJO using Jackson. However, as this JSON contains a nested map of objects, when i de-serialize it to the POJO, the timeseries information is not converted to the POJO. I am only able to get the metadata part and the date part in the timeseries block. The other fields in the times…
How to deserialize from Number value to int (error – no int/Int-argument constructor/factory method to deserialize from Number value)
I have two classes Flight and Ticket. One flight can has lots of tickets, so Ticket has foreign key flight_id. Here is my database with tables flight and ticket. Here is my json request (from Mozilla debugger), which I want to save in the database. You can see flight_id parameter, but I can’t save it to…
Parse JSON Data using POJO, Where key name is numeric
I’m trying to parse a special JSON data using Wrapper class, special means a JSON which have numeric keys like below : I know how to parse JSON data using POJO, But in this case java is not accepting the numeric as Keys. Wrapper/POJO Class I don’t want to go with JSON object based parsing. Is Anyo…