Class Serializers

java.lang.Object
io.helidon.json.binding.Serializers

public final class Serializers extends Object
Utility class for serialization operations.
  • Method Details

    • serialize

      public static <T> void serialize(JsonGenerator generator, JsonSerializer<T> serializer, T instance, String key, boolean writeNulls)
      Serializes a value with a key using the provided serializer.
      Type Parameters:
      T - the type of the instance
      Parameters:
      generator - the JSON generator
      serializer - the serializer to use
      instance - the instance to serialize
      key - the key to write
      writeNulls - whether to write null values
    • serialize

      public static <T extends Optional<?>> void serialize(JsonGenerator generator, JsonSerializer<T> serializer, T instance, String key, boolean writeNulls)
      Serializes an Optional value with a key using the provided serializer.
      Type Parameters:
      T - the type of the instance
      Parameters:
      generator - the JSON generator
      serializer - the serializer to use
      instance - the instance to serialize
      key - the key to write
      writeNulls - whether to write null values
    • serialize

      public static void serialize(JsonGenerator generator, JsonSerializer<OptionalInt> serializer, OptionalInt instance, String key, boolean writeNulls)
      Serializes an OptionalInt value with a key using the provided serializer.
      Parameters:
      generator - the JSON generator
      serializer - the serializer to use
      instance - the instance to serialize
      key - the key to write
      writeNulls - whether to write null values
    • serialize

      public static void serialize(JsonGenerator generator, JsonSerializer<OptionalLong> serializer, OptionalLong instance, String key, boolean writeNulls)
      Serializes an OptionalLong value with a key using the provided serializer.
      Parameters:
      generator - the JSON generator
      serializer - the serializer to use
      instance - the instance to serialize
      key - the key to write
      writeNulls - whether to write null values
    • serialize

      public static void serialize(JsonGenerator generator, JsonSerializer<OptionalDouble> serializer, OptionalDouble instance, String key, boolean writeNulls)
      Serializes an OptionalDouble value with a key using the provided serializer.
      Parameters:
      generator - the JSON generator
      serializer - the serializer to use
      instance - the instance to serialize
      key - the key to write
      writeNulls - whether to write null values