use of io.micronaut.json.codec.JsonMediaTypeCodec in project micronaut-core by micronaut-projects.
the class JsonViewMediaTypeCodecFactory method resolveJsonViewCodec.
/**
* Creates a {@link JsonMediaTypeCodec} for the view class (specified as the JsonView annotation value).
* @param viewClass The view class
* @return The codec
*/
@Override
@NonNull
public JsonMediaTypeCodec resolveJsonViewCodec(@NonNull Class<?> viewClass) {
ArgumentUtils.requireNonNull("viewClass", viewClass);
JsonMediaTypeCodec codec = jsonViewCodecs.get(viewClass);
if (codec == null) {
codec = (JsonMediaTypeCodec) jsonCodec.cloneWithViewClass(viewClass);
jsonViewCodecs.put(viewClass, codec);
}
return codec;
}
use of io.micronaut.json.codec.JsonMediaTypeCodec in project micronaut-core by micronaut-projects.
the class DefaultHttpClient method createDefaultMediaTypeRegistry.
private static MediaTypeCodecRegistry createDefaultMediaTypeRegistry() {
JsonMapper mapper = new JacksonDatabindMapper();
ApplicationConfiguration configuration = new ApplicationConfiguration();
return MediaTypeCodecRegistry.of(new JsonMediaTypeCodec(mapper, configuration, null), new JsonStreamMediaTypeCodec(mapper, configuration, null));
}
Aggregations