public class CharacterEscapesJsonFactoryDecorator extends Object implements JsonFactoryDecorator
JsonFactoryDecorator
that can be used to customize the JsonFactory.setCharacterEscapes(CharacterEscapes)
.
For example, you could change the escape sequence used for newline characters from '\n' to '
'Modifier and Type | Class and Description |
---|---|
static class |
CharacterEscapesJsonFactoryDecorator.Escape
Defines how a character will be escaped whenever that character is attempted to be written by a JsonGenerator.
|
Constructor and Description |
---|
CharacterEscapesJsonFactoryDecorator() |
Modifier and Type | Method and Description |
---|---|
void |
addEscape(CharacterEscapesJsonFactoryDecorator.Escape escape) |
JsonFactory |
decorate(JsonFactory factory)
Decorates the given
JsonFactory . |
MappingJsonFactory |
decorate(MappingJsonFactory factory)
Deprecated.
|
boolean |
isIncludeStandardAsciiEscapesForJSON() |
void |
removeEscape(CharacterEscapesJsonFactoryDecorator.Escape escape) |
void |
setIncludeStandardAsciiEscapesForJSON(boolean includeStandardAsciiEscapesForJSON) |
public CharacterEscapesJsonFactoryDecorator()
@Deprecated public MappingJsonFactory decorate(MappingJsonFactory factory)
JsonFactoryDecorator
MappingJsonFactory
.
By default, returns the given factory unchanged.decorate
in interface JsonFactoryDecorator
public JsonFactory decorate(JsonFactory factory)
JsonFactoryDecorator
JsonFactory
.
By default, for backwards compatibility purposes,
this assumes the given factory is a MappingJsonFactory
,
and calls JsonFactoryDecorator.decorate(MappingJsonFactory)
so that existing
implementations that only implemented JsonFactoryDecorator.decorate(MappingJsonFactory)
continue to work.
In a future release, this will be changed to return the given factory by default,
and JsonFactoryDecorator.decorate(MappingJsonFactory)
will be removed.
It is recommended to only override JsonFactoryDecorator.decorate(JsonFactory)
.
Existing implementations should migrate to only overriding JsonFactoryDecorator.decorate(JsonFactory)
so that they will continue to work after JsonFactoryDecorator.decorate(MappingJsonFactory)
is removed.
Note that the default JsonFactory
created by logstash-logback-encoder
is a MappingJsonFactory
, but can be changed by JsonFactoryDecorator
s
to any subclass of JsonFactory
.decorate
in interface JsonFactoryDecorator
JsonFactory
public boolean isIncludeStandardAsciiEscapesForJSON()
public void setIncludeStandardAsciiEscapesForJSON(boolean includeStandardAsciiEscapesForJSON)
public void addEscape(CharacterEscapesJsonFactoryDecorator.Escape escape)
public void removeEscape(CharacterEscapesJsonFactoryDecorator.Escape escape)
Copyright © 2020. All rights reserved.