Skip to content

SerializerBuildHelper

Creating Serializer (Expression) for Object

createSerializerForObject(
  inputObject: Expression,
  fields: Seq[(String, Expression)]): Expression

createSerializerForObject creates a CreateNamedStruct expression with argumentsForFieldSerializer for the given fields.

Only when the given Expression is nullable, createSerializerForObject wraps the CreateNamedStruct expression with an If expression with IsNull child expression, a null Literal and the CreateNamedStruct expressions (for the positive and negative branches of the If expression, respectively).

createSerializerForObject is used when:

  • JavaTypeInference utility is used to serializerFor
  • ScalaReflection utility is used to create a serializer (for Scala Products or DefinedByConstructorParamss)

argumentsForFieldSerializer

argumentsForFieldSerializer(
  fieldName: String,
  serializerForFieldValue: Expression): Seq[Expression]

argumentsForFieldSerializer creates a two-element collection of the following:

  1. Literal for the given fieldName
  2. serializerForFieldValue Expression