Java EE 7 Json.createBuilderFactory (config) - what can you do with a non-zero configuration?

I tried to use Java EE 7 JsonBuilder, and I am having trouble understanding the configuration parameter for createBuilderFactory. Yes, you can leave it empty or null, but what else can you do?

JsonBuilderFactory factory = Json.createBuilderFactory(config); JsonObject value = factory.createObjectBuilder() .add("firstName", "John") .add("lastName", "Smith") .add("age", 25).build(); 

What can be done with the configuration? The distance between colons or commas? Line breaks for each array? I don't know how to look at the source code, and it does not seem to be documented on the Java EE page for json ( http://docs.oracle.com/javaee/7/api/index.html?javax/json/Json.html )

+6
source share
1 answer

I think it really depends on the implementation of Java EE 7. For Glass Fish, you can just pass null for the Json.createXXXFactory () methods, except for the Json.createWriterFactory / createGeneratorFactory () method, which you could pass in with the configuration parameter, whether do pretty printed or not.

  Map<String, Object> config = new HashMap<String, Object>(); //if you need pretty printing config.put("javax.json.stream.JsonGenerator.prettyPrinting", Boolean.valueOf(true)); JsonWriterFactory factory = Json.createWriterFactory(config); 
+5
source

Source: https://habr.com/ru/post/975041/


All Articles