org.apache.johnzon.core.JsonProviderImpl Java Examples
The following examples show how to use
org.apache.johnzon.core.JsonProviderImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluralRecordExtension.java From component-runtime with Apache License 2.0 | 6 votes |
private Jsonb createPojoJsonb() { final JsonbBuilder jsonbBuilder = JsonbBuilder.newBuilder().withProvider(new JsonProviderImpl() { @Override public JsonGeneratorFactory createGeneratorFactory(final Map<String, ?> config) { return new RecordJsonGenerator.Factory(() -> new RecordBuilderFactoryImpl("test"), () -> getJsonb(createPojoJsonb()), config); } }); try { // to passthrough the writer, otherwise RecoderJsonGenerator is broken final Field mapper = jsonbBuilder.getClass().getDeclaredField("builder"); if (!mapper.isAccessible()) { mapper.setAccessible(true); } MapperBuilder.class.cast(mapper.get(jsonbBuilder)).setDoCloseOnStreams(true); } catch (final Exception e) { throw new IllegalStateException(e); } return jsonbBuilder.build(); }
Example #2
Source File: ClientsJsonProvider.java From java-json-benchmark with MIT License | 6 votes |
public ClientsJsonProvider() { jsonioStreamOptions.put(JsonReader.USE_MAPS, true); jsonioStreamOptions.put(JsonWriter.TYPE, false); // set johnson JsonReader (default is `JsonProvider.provider()`) javax.json.spi.JsonProvider johnzonProvider = new JsonProviderImpl(); johnzon = new org.apache.johnzon.mapper.MapperBuilder() .setReaderFactory(johnzonProvider.createReaderFactory(Collections.emptyMap())) .setGeneratorFactory(johnzonProvider.createGeneratorFactory(Collections.emptyMap())) .setAccessModeName("field") // default is "strict-method" which doesn't work nicely with public attributes .build(); TypeConverterManager joddTypeConverterManager = TypeConverterManager.get(); joddTypeConverterManager.register(UUID.class, (TypeConverter<UUID>) value -> UUID.fromString((String)value)); joddTypeConverterManager.register(LocalDate.class, (TypeConverter<LocalDate>) value -> LocalDate.parse((String)value)); joddTypeConverterManager.register(OffsetDateTime.class, (TypeConverter<OffsetDateTime>) value -> OffsetDateTime.parse((String)value)); }
Example #3
Source File: UsersJsonProvider.java From java-json-benchmark with MIT License | 5 votes |
public UsersJsonProvider() { jacksonAfterburner.registerModule(new AfterburnerModule()); jsonioStreamOptions.put(JsonReader.USE_MAPS, true); jsonioStreamOptions.put(JsonWriter.TYPE, false); // set johnson JsonReader (default is `JsonProvider.provider()`) javax.json.spi.JsonProvider johnzonProvider = new JsonProviderImpl(); johnzon = new org.apache.johnzon.mapper.MapperBuilder() .setReaderFactory(johnzonProvider.createReaderFactory(Collections.emptyMap())) .setGeneratorFactory(johnzonProvider.createGeneratorFactory(Collections.emptyMap())) .setAccessModeName("field") // default is "strict-method" which doesn't work nicely with public attributes .build(); }
Example #4
Source File: JohnzonProcessor.java From camel-quarkus with Apache License 2.0 | 4 votes |
@BuildStep ReflectiveClassBuildItem initReflectiveClassBuildItem() { return new ReflectiveClassBuildItem(false, false, JsonProviderImpl.class); }