Module org.eclipse.yasson
Class NullVisibilitySwitcher
java.lang.Object
org.eclipse.yasson.internal.serializer.NullVisibilitySwitcher
- All Implemented Interfaces:
ModelSerializer
Switching mechanism for default null value visibility in the JSON.
Some constructs such as arrays, collections etc. require to have nulls serialized into the JSON by default.
This class switches from the default parent null visibility to the current construct visibility. As soon as the current
construct is serialized, visibility is switched back to the parent ones.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
serialize
(Object value, jakarta.json.stream.JsonGenerator generator, SerializationContextImpl context) Serialize provided value or delegate serialization to the next serializer.
-
Field Details
-
nullsEnabled
private final boolean nullsEnabled -
delegate
-
-
Constructor Details
-
NullVisibilitySwitcher
NullVisibilitySwitcher(boolean nullsEnabled, ModelSerializer delegate)
-
-
Method Details
-
serialize
public void serialize(Object value, jakarta.json.stream.JsonGenerator generator, SerializationContextImpl context) Description copied from interface:ModelSerializer
Serialize provided value or delegate serialization to the next serializer.- Specified by:
serialize
in interfaceModelSerializer
- Parameters:
value
- value to be serializedgenerator
- json generatorcontext
- serialization context
-