CodecMakerConfig

com.github.plokhotnyuk.jsoniter_scala.macros.CodecMakerConfig
See theCodecMakerConfig companion object

Configuration parameter for JsonCodecMaker.make() call.

BEWARE: a parameter of the make macro should not depend on code from the same compilation module where it is called. Use a separated submodule of the project to compile all such dependencies before their usage for generation of codecs.

Examples of fieldNameMapper, javaEnumValueNameMapper, and adtLeafClassNameMapper functions that have no dependencies in the same compilation module are: JsonCodecMaker.enforceCamelCase, JsonCodecMaker.enforce_snake_case, JsonCodecMaker.enforce-kebab-case, and JsonCodecMaker.simpleClassName. Or their composition like: s => JsonCodecMaker.enforce_snake_case(JsonCodecMaker.simpleClassName(s))

Attributes

adtLeafClassNameMapper

the function of mapping from string of case class/object full name to string value of discriminator field (a function that truncate to simple class name by default)

allowRecursiveTypes

a flag that turns on support of recursive types (turned off by default to avoid stack overflow errors with untrusted input)

bigDecimalDigitsLimit

an exclusive limit for accepted number of mantissa digits of to be parsed before rounding with the precision specified for 'BigDecimal' values (308 by default, don't set too big limit to avoid of OOM errors or attacks from untrusted input)

bigDecimalPrecision

a precision in 'BigDecimal' values (34 by default that is a precision for decimal128, see java.math.MathContext.DECIMAL128.getPrecision, don't set too big or infinite precision to avoid attacks from untrusted input)

bigDecimalScaleLimit

an exclusive limit for accepted scale in 'BigDecimal' values (6178 by default that is a range for decimal128, don't set too big scale limit to avoid attacks from untrusted input)

bigIntDigitsLimit

an exclusive limit for accepted number of decimal digits in 'BigInt' values (308 by default, don't set too big limit to avoid of OOM errors or attacks from untrusted input)

bitSetValueLimit

an exclusive limit for accepted numeric values in bit sets (1024 by default, don't set too big limit to avoid of OOM errors or attacks from untrusted input)

discriminatorFieldName

an optional name of discriminator field, where None can be used for alternative representation of ADTs without the discriminator field (Some("type") by default)

fieldNameMapper

the partial function of mapping from string of case class field name to JSON key (an identity function by default)

isStringified

a flag that turns on stringification of number or boolean values of collections, options and value classes (turned off by default)

javaEnumValueNameMapper

the partial function of mapping from string of Java enum name to JSON key (an identity function by default)

mapAsArray

a flag that turns on serialization and parsing of maps as a JSON array (or sequences of tuples) instead of a JSON object, that allow to use 'JsonValueCodec' for encoding and decoding of keys (turned off by default)

mapMaxInsertNumber

a max number of inserts into maps (1024 by default to limit attacks from untrusted input that exploit worst complexity for inserts, see https://github.com/scala/bug/issues/11203 )

requireCollectionFields

a flag that turn on checking of presence of collection fields and forces serialization when they are empty

requireDiscriminatorFirst

a flag that turns off limitation for a position of the discriminator field to be the first field of the JSON object (turned on by default to avoid CPU overuse when the discriminator appears in the end of JSON objects, especially nested)

setMaxInsertNumber

a max number of inserts into sets excluding bit sets (1024 by default to limit attacks from untrusted input that exploit worst complexity for inserts, see https://github.com/scala/bug/issues/11203 )

skipNestedOptionValues

a flag that turns on skipping of some values for nested more than 2-times options and allow using Option[Option[_]] field values to distinguish null and missing field cases

skipUnexpectedFields

a flag that turns on skipping of unexpected fields or in other case a parse exception will be thrown (turned on by default)

transientDefault

a flag that turns on skipping serialization of fields that have same values as default values defined for them in the primary constructor (turned on by default)

transientEmpty

a flag that turns on skipping serialization of fields that have empty values of arrays or collections (turned on by default)

transientNone

a flag that turns on skipping serialization of fields that have empty values of options (turned on by default)

useScalaEnumValueId

a flag that turns on using of ids for parsing and serialization of Scala enumeration values

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object CodecMakerConfig.type

Members list

Concise view

Value members

Concrete methods

def withAdtLeafClassNameMapper(adtLeafClassNameMapper: String => String): CodecMakerConfig
def withAllowRecursiveTypes(allowRecursiveTypes: Boolean): CodecMakerConfig
def withBigDecimalDigitsLimit(bigDecimalDigitsLimit: Int): CodecMakerConfig
def withBigDecimalPrecision(bigDecimalPrecision: Int): CodecMakerConfig
def withBigDecimalScaleLimit(bigDecimalScaleLimit: Int): CodecMakerConfig
def withBigIntDigitsLimit(bigIntDigitsLimit: Int): CodecMakerConfig
def withBitSetValueLimit(bitSetValueLimit: Int): CodecMakerConfig
def withDiscriminatorFieldName(discriminatorFieldName: Option[String]): CodecMakerConfig
def withFieldNameMapper(fieldNameMapper: PartialFunction[String, String]): CodecMakerConfig
def withIsStringified(isStringified: Boolean): CodecMakerConfig
def withJavaEnumValueNameMapper(javaEnumValueNameMapper: PartialFunction[String, String]): CodecMakerConfig
def withMapAsArray(mapAsArray: Boolean): CodecMakerConfig
def withMapMaxInsertNumber(mapMaxInsertNumber: Int): CodecMakerConfig
def withRequireCollectionFields(requireCollectionFields: Boolean): CodecMakerConfig
def withRequireDiscriminatorFirst(requireDiscriminatorFirst: Boolean): CodecMakerConfig
def withSetMaxInsertNumber(setMaxInsertNumber: Int): CodecMakerConfig
def withSkipNestedOptionValues(skipNestedOptionValues: Boolean): CodecMakerConfig
def withSkipUnexpectedFields(skipUnexpectedFields: Boolean): CodecMakerConfig
def withTransientDefault(transientDefault: Boolean): CodecMakerConfig
def withTransientEmpty(transientEmpty: Boolean): CodecMakerConfig
def withTransientNone(transientNone: Boolean): CodecMakerConfig
def withUseScalaEnumValueId(useScalaEnumValueId: Boolean): CodecMakerConfig

Concrete fields

val adtLeafClassNameMapper: NameMapper
val allowRecursiveTypes: Boolean
val discriminatorFieldName: Option[String]
val fieldNameMapper: NameMapper
val isStringified: Boolean
val javaEnumValueNameMapper: NameMapper
val mapAsArray: Boolean
val transientDefault: Boolean
val transientEmpty: Boolean
val transientNone: Boolean
val useScalaEnumValueId: Boolean