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
0
votes
1 answer

Deployed Web application getting nosuchmethod error for javax.json.JsonValue.asJsonArray - Jboss eap 7.0 linux server

I have a web application deployed to jboss eap 7.0 on linux. Within my java code I am using javax.json.JsonValue.asJsonArray method. When I run locally on tomcat all runs fine. Once I deploy to Jboss I get a nosuchmethod error on asJsonArray…
0
votes
0 answers

How to query JSON with wildcards and modify the results?

I'd like to be able to query a JSON object and modify it in a way that is structure-agnostic and doesn't involve marshalling to POJOs. Here's an example to illustrate. { "user" : [ { "username" : "foo", "user-id" : "1234", "name" : { …
Sabrina Star
  • 1
  • 1
  • 1
0
votes
1 answer

Render JSON with two objects in javax.json

Given these two annotated classes : public class Clazz1 { @JsonbProperty("val11") String value11; @JsonbProperty("val12") String value12; ..... } public class Clazz2 { @JsonbProperty("val21") String value21; …
ps0604
  • 1,227
  • 23
  • 133
  • 330
0
votes
1 answer

Java: Generating JSON: Getting exception when try to name object & array

I`m trying to generate JSON with structure like this: "rows": [ { "object": { "id": "1" }, "values": [ "111", "reg text", "11" ] } ] and here are the…
0
votes
2 answers

jax-rs consuming org.json.JSONObject respsonds with Exception

I am trying to build a rest api that should consume json/x-application data. Now I have looked into two libraries javax.json-api and org.json for handling the data. Example JSON: { "error": "false", "error_msg": "", "version":…
Ilir
  • 430
  • 2
  • 7
  • 19
0
votes
3 answers

Looping values in JsonObject

I have given myself a task to loop values inside an JsonObject; for instance, I want my json to look like this: { "cusEmail": "...", "totalQuantity": 11, "totalCost": 296.89, "phoneNumber": "844 463 9211", …
DESH
  • 530
  • 2
  • 11
  • 29
0
votes
1 answer

trouble with parse data from JSON format

I have a data in JSON format. For example: { "status": "ok", "meta": { "count": 1 }, "data": { "531446": { "global_rating": 6595, "statistics": { "random": { …
0
votes
0 answers

gradle: Java API for JSON Processing (JSR 374)

How are the dependencies for JSON Processing, JSR 374, handled from gradle? Working examples would be greatly appreciated. context: below is what I have with maven; looking to migrate this to gradle. build is ok, even if there are…
Thufir
  • 8,216
  • 28
  • 125
  • 273
-1
votes
3 answers

How to convert Map into javax.json.JsonObject?

I can do so: Map mapA = ...; Map mapB = mapA.entrySet().stream() .collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue )); But when I'm trying to do this: ...…
tom
  • 2,137
  • 2
  • 27
  • 51
-2
votes
1 answer

JSON API for Java. JsonParser to JsonObjects and JsonArrays

I thanks for taking a look. I'm working on a problem where I need to be able to get a Json into memory and be able to "navigate" around the keys. I am able to use the Json.createParser() method and use the FileReader in the args to get the file in…
JoeS
  • 25
  • 2
1
2