Questions tagged [javax.json]

Provides an object model API to process JSON. (JSR 374)

JSR 374 specifies the Java API for JSON Processing.

From the Javadoc description:

Provides an object model API to process JSON.

The object model API is a high-level API that provides immutable object models for JSON object and array structures. These JSON structures are represented as object models using the Java types JsonObject and JsonArray. The interface javax.json.JsonObject provides a Map view to access the unordered collection of zero or more name/value pairs from the model. Similarly, the interface JsonArray provides a List view to access the ordered sequence of zero or more values from the model.

The object model API uses builder patterns to create these object models. The classes JsonObjectBuilder and JsonArrayBuilder provide methods to create models of type JsonObject and JsonArray respectively.

These object models can also be created from an input source using the class JsonReader. Similarly, these object models can be written to an output source using the class JsonWriter.

25 questions
8
votes
1 answer

How to clone JsonObject (shadow and deep) following JSR-353 (JSON-P) spec

I convert the JsonObject to String, then parsed them back. public static JsonObject clone(JsonObject o) { if (o == null) return null; StringWriter buffer = new StringWriter(); JsonWriter writer = Json.createWriter(buffer); …
sca.
  • 365
  • 4
  • 14
3
votes
1 answer

deploying java web app to heroku: NoClassDefFoundError caused by ClassNotFoundException

I followed this instruction: https://devcenter.heroku.com/articles/deploying-java to deploy a java web app to heroku. The content of my Procfile is the following: web: java $JAVA_OPTS -cp target/classes:target/dependency/*…
2
votes
1 answer

How to Iterate more JsonObject using javax.json lib

This is my first post so thank you. I'm using javax.json library to read a imported file.txt which contains a Json. this is the text: [{ "role" : "role1", "db" : "db_admin", "flag" : false, "roles"…
2
votes
0 answers

Volley POST error "Unexpected response code 400"

I recently started an Android Project (native shopping app) for practice. My problem is saving the customers order data with Volley. I first did it with Maps and it only saved the customer's details, but not what the customer ordered, that is,…
DESH
  • 530
  • 2
  • 11
  • 29
1
vote
1 answer

javax.json module not found building JavaFX application with Gradle

I am trying to run a modular JavaFX application, with few other modular and non modular dependencies, using Gradle, but I am stuck with dependencies resolution. The project is in Eclipse, using OpenJDK 14-. I have been able ot run, build and package…
CT95
  • 107
  • 1
  • 11
1
vote
0 answers

Jackson ObjectMapper valueToTree method also write valueType and integral but no actual value

I am trying to convert a JAVA POJO object with a JsonObject to a String as following: class MyPojo { public MyPojo(String sName, JsonObject obj) { this.sName = sName; this.tJsonObj = obj; } public String…
mkag
  • 106
  • 12
1
vote
1 answer

JSON Object is built incorrectly

I am trying to get data from my SQL. The Data from my Servlet is put into an array list. After that I build a JSON object and pass it to my JSP file. Now my browser is receiving the Objects really weird. Also I can only call the first 3 of them. I…
D.Doe
  • 89
  • 2
  • 10
1
vote
1 answer

How to use replace(K,V) in javax.json.JsonObject?

I need to read a JsonObject, modify a value, then go on. Let's say: { "aKey": "old value", , "anotherKey": "another value" } should be changed to: { "aKey": "new value", "anotherKey": "another value" } I read that JsonObject is immutable, it's in…
fresko
  • 1,890
  • 2
  • 24
  • 25
1
vote
1 answer

Converting from javax.json.JsonArray to org.json.JSONArray

Is it possible to convert from the newer EJB JSON libraries to the older org.json ones without having to rely on org.json.simple or GSON? In the case below, "buttons" is a populated JsonArray and I'm trying to copy it into a JSONArray for legacy…
Alkanshel
  • 4,198
  • 1
  • 35
  • 54
1
vote
1 answer

Java JSON: get object-value without quotes?

I parse a JSON string. How can I get the value of an object without the quotes? I get it with lists but it is not working with objects. import javax.json.*; import javax.json.stream.*; ... String s="{ \"foo\" : [ \"abc\", \"def\" ], \"bar\" :…
chris01
  • 10,921
  • 9
  • 54
  • 93
1
vote
1 answer

javax.json serializer/deserializer for Gson

I'm trying to write a general Gson serializer/deserializer for java.javax.JsonObjects: public static class JavaxJsonObjConverter implements JsonSerializer, JsonDeserializer { @Override public JsonObject…
piyo
  • 461
  • 1
  • 5
  • 18
1
vote
1 answer

java.lang.NoClassDefFoundError: javax/json/Json no maven or IDE

I am trying a simple json java program (no maven or IDE). This is my java file: import javax.json.*; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.JsonWriter; class JsonTest { public…
Bhavik
  • 346
  • 4
  • 11
0
votes
1 answer

How to write a GPath expression when the RestAssured response is simply an array with out a name

After my RestAssured code executed, I got a response body like this(which is valid, since I verified it in Postman also) [ { "team": null, "name": "Automation", "id": "977638c2-0095-42fb-a3fb-3ef442cc61e2" }, { …
PraNuta
  • 629
  • 3
  • 12
  • 33
0
votes
1 answer

Converting list data into Json using javax package classes

I can not use any third party library so I have mentioned in subject line. this line throwing exception. obj.put("CanonicalName", data.getItemname()); I have a list which is of EntityData type. EntityData is POJO which has 2 columns with getter…
user14046507
0
votes
2 answers

Map a String into JSON using JsonGenerator

Given is a JSON array [ { "ref": "idValue", "data": { "filter": [ { "property": "number" } ], "stateId": "contacts" } } ] I…
Timz
  • 412
  • 2
  • 13
1
2