Questions tagged [jsonnode]

89 questions
12
votes
3 answers

Cannot construct instance of `com.domain.User` (no Creators, like default constructor, exist): cannot deserialize from Object value

I have a controller that accepts ObjectNode as @RequestBody. That ObjectNode represents json with some user data { "given_name":"ana", "family_name": "fabry", "email": "fabry@gmail.com", "password": "mypass", "gender":…
user9347049
  • 1,927
  • 3
  • 27
  • 66
10
votes
3 answers

How to compare two JsonNodes with Jackson?

I have a method which compares two objects, but I don't know how to compare JsonNode by Jackson library. I want get something like that: private boolean test(JsonNode source) { JsonNode test = compiler.process(file); return…
John
  • 1,375
  • 4
  • 17
  • 40
8
votes
4 answers

Get all the keys in a JSON string JsonNode in java

I have a json string which I need to validate and find any other keys other than in a list is there in the json string. The sample json string is { "required" : true, "requiredMsg" : "Title needed", "choices" : [ "a", "b", "c", "d" ], …
Senchu Thomas
  • 518
  • 3
  • 9
  • 24
6
votes
1 answer

Using Jackson to add XML attributes to manually-built node-tree

I'm trying to set up code to create a node tree using Jackson which can then be used to write either JSON or XML. I've created the node tree manually like so: XmlMapper nodeMapper = new XmlMapper(); ObjectNode rootNode =…
Alexander
  • 261
  • 4
  • 18
5
votes
1 answer

Jackson: Check if ArrayNode contains JsonNode

I am using the Jackson JSON library and its Tree Model system (JsonNode) in my Java application. In this, I need to check if an ArrayNode contains a given JsonNode. I was looking through the JavaDocs and I did not see any sort of .contains() method…
Andrew
  • 902
  • 1
  • 11
  • 28
3
votes
2 answers

check if a jsonNode contains a specific key then EXTRACT its value once it exists

I have this String an I covered it to jsonNode using the ObjectMapper. Then I tried to look for a pecific key in this jsonNode so I used the ".has" but it did not work !! Here is what I did : { "links": { "data": { "self":…
MAryem
  • 182
  • 1
  • 2
  • 14
3
votes
1 answer

What is the difference between asDouble() and doubleValue() in Jackson API?

I am little confused while using these methods. If both methods return same value then why Jackson API has provided two different methods?
3
votes
1 answer

Parse a JSONNode using Java 8 stream API

I'm reading all Objects from Salesforce environment using Java, it's working fine but below code is taking 10 mins to convert the JSON into Java ArrayList. I was thinking if I can use Java - 8 stream API to parallel the parsing logic. Below is my…
Roul
  • 945
  • 1
  • 12
  • 34
2
votes
1 answer

How to have JsonNode.ToJsonString(...) produce properties in alphabetic order?

I am using JsonNode.ToJsonString(...) in my unit tests. Unfortunately the property order in the serialized string seems to be depend the runtime order how the child nodes and value nodes were added. However to phrase a unit test expectation the…
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
2
votes
1 answer

How to save a JsonNode param (micronaut + kotlin) as a jsonb in postgres database

I'm trying to save an entity that has a JsonNode attribute and has to be converted to jsonb to be stores in a postgres database. This is the database table: CREATE TABLE IF NOT EXISTS configuration_data ( id SERIAL NOT NULL PRIMARY KEY, …
Lorena
  • 93
  • 6
2
votes
1 answer

How to create an empty JsonNode?

I am trying to set an empty node as a value of some other json node. new JsonNode() didn't work as that is protected. Example: JsonNode jsonNode = externalSource(); // <--This is the parent json node ((ObjectNode) jsonNode).set("fieldName", new…
Mooncrater
  • 4,146
  • 4
  • 33
  • 62
2
votes
2 answers

Dynamic Json string to Java Object

How would you map this JSON string with dynamic properties to a Java object? { 'name' : 'John', 'lastname': 'Doe', 'dynamicProperty1': { 'label' : 'size', 'value': 'large'}, 'dynamicProperty2': { 'label' : 'color', 'value':…
2
votes
3 answers

How to separate JSON object on pieces?

I am using Jackson and I have the following JSON structure. { "person": { "person1": {"name": "daniel", "age": "17"}, "person2": {"name": "lucy", "age": "19"} } } And I want to get the following result or separate them. Json1: { …
Daniel
  • 181
  • 4
  • 13
2
votes
1 answer

JOOQ Code Generator skips a class that contains a JsonNode field

I'm currently working on a project that uses JOOQ for the sql transactions with a Postgres. But one of the models has a field of JsonNode type ( jsonb in postgres ). JOOQ code generator does not support this so I added a custom binding which was…
Michael Michailidis
  • 1,002
  • 1
  • 8
  • 21
2
votes
2 answers

com.fasterxml.jackson.databind.node.IntNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode

I am trying to learn DynamoDb and trying loading data from json to table using example in Amazon developer guide but i am getting below exception: com.fasterxml.jackson.databind.node.IntNode cannot be cast to…
Manish
  • 1,274
  • 3
  • 22
  • 59
1
2 3 4 5 6