DynamicValue

zio.blocks.schema.DynamicValue
See theDynamicValue companion object
sealed trait DynamicValue

A schema-less, dynamically-typed representation of any value.

DynamicValue provides a universal data model that can represent any structured value without requiring compile-time type information. It serves as an intermediate representation for serialization, schema evolution, data transformation, and cross-format conversion.

The ADT consists of six cases:

Navigation and modification use DynamicOptic, a path-based lens system for traversing and updating nested structures.

Attributes

See also

Schema.toDynamicValue for converting typed values to DynamicValue

Schema.fromDynamicValue for converting DynamicValue back to typed values

DynamicOptic for path-based navigation

Companion
object
Source
DynamicValue.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Map
object Null
class Primitive
class Record
class Sequence
class Variant
Show all

Members list

Value members

Abstract methods

def compare(that: DynamicValue): Int

Attributes

Source
DynamicValue.scala
def typeIndex: Int

Returns a numeric index representing this value's type, used for ordering values of different types. The ordering is: Primitive(0) < Record(1) < Variant(2) < Sequence(3) < Map(4) < Null(5).

Returns a numeric index representing this value's type, used for ordering values of different types. The ordering is: Primitive(0) < Record(1) < Variant(2) < Sequence(3) < Map(4) < Null(5).

Attributes

Source
DynamicValue.scala

Returns the DynamicValueType of this DynamicValue.

Returns the DynamicValueType of this DynamicValue.

Attributes

Source
DynamicValue.scala

Concrete methods

final def <(that: DynamicValue): Boolean

Attributes

Source
DynamicValue.scala
final def <=(that: DynamicValue): Boolean

Attributes

Source
DynamicValue.scala
final def >(that: DynamicValue): Boolean

Attributes

Source
DynamicValue.scala
final def >=(that: DynamicValue): Boolean

Attributes

Source
DynamicValue.scala
def as(t: DynamicValueType): Option[t.Type]

Narrows this DynamicValue to the specified type, returning Some if the types match or None otherwise.

Narrows this DynamicValue to the specified type, returning Some if the types match or None otherwise.

Attributes

Source
DynamicValue.scala
def asPrimitive[A](pt: PrimitiveType[A]): Option[A]

Extracts a primitive value of type A if this is a Primitive with matching type.

Extracts a primitive value of type A if this is a Primitive with matching type.

Attributes

Source
DynamicValue.scala
def caseName: Option[String]

Returns the case name if this is a Variant, otherwise None.

Returns the case name if this is a Variant, otherwise None.

Attributes

Source
DynamicValue.scala
def caseValue: Option[DynamicValue]

Returns the case value if this is a Variant, otherwise None.

Returns the case value if this is a Variant, otherwise None.

Attributes

Source
DynamicValue.scala
def check(schema: DynamicSchema): Option[SchemaError]

Validates this value against a DynamicSchema.

Validates this value against a DynamicSchema.

Value parameters

schema

The schema to validate against

Attributes

Returns

None if this value conforms to the schema, or Some(SchemaError) describing the validation failure

See also

DynamicSchema.check for the underlying validation logic

Source
DynamicValue.scala
def conforms(schema: DynamicSchema): Boolean

Tests whether this value conforms to a DynamicSchema.

Tests whether this value conforms to a DynamicSchema.

Value parameters

schema

The schema to validate against

Attributes

Returns

true if this value passes all validation checks, false otherwise

Source
DynamicValue.scala

Deletes the value at the given path. If the path doesn't exist, returns the original DynamicValue unchanged.

Deletes the value at the given path. If the path doesn't exist, returns the original DynamicValue unchanged.

Attributes

Source
DynamicValue.scala

Deletes the value at the given path. Returns Left with an error if the path doesn't exist.

Deletes the value at the given path. Returns Left with an error if the path doesn't exist.

Attributes

Source
DynamicValue.scala

Computes the difference between this DynamicValue and another, producing a zio.blocks.schema.patch.DynamicPatch that can transform this value into that.

Computes the difference between this DynamicValue and another, producing a zio.blocks.schema.patch.DynamicPatch that can transform this value into that.

The diff algorithm produces minimal patches using type-appropriate operations: numeric deltas for numbers, string edit operations for text, and structural diffs for records, sequences, and maps.

Attributes

Source
DynamicValue.scala

Recursively removes empty Records, Sequences, and Maps.

Recursively removes empty Records, Sequences, and Maps.

Attributes

Source
DynamicValue.scala

Recursively removes all Null values from containers.

Recursively removes all Null values from containers.

Attributes

Source
DynamicValue.scala

Recursively removes all Primitive(Unit) values from containers.

Recursively removes all Primitive(Unit) values from containers.

Attributes

Source
DynamicValue.scala

Returns the elements if this is a Sequence, otherwise an empty Chunk.

Returns the elements if this is a Sequence, otherwise an empty Chunk.

Attributes

Source
DynamicValue.scala

Returns the entries if this is a Map, otherwise an empty Chunk.

Returns the entries if this is a Map, otherwise an empty Chunk.

Attributes

Source
DynamicValue.scala
def fields: Chunk[(String, DynamicValue)]

Returns the fields if this is a Record, otherwise an empty Chunk.

Returns the fields if this is a Record, otherwise an empty Chunk.

Attributes

Source
DynamicValue.scala
def foldDown[B](z: B)(f: (DynamicOptic, DynamicValue, B) => B): B

Folds over the DynamicValue structure top-down. The function receives the current path, the DynamicValue, and the accumulator. Parent values are folded before their children.

Folds over the DynamicValue structure top-down. The function receives the current path, the DynamicValue, and the accumulator. Parent values are folded before their children.

Attributes

Source
DynamicValue.scala
def foldDownOrFail[B](z: B)(f: (DynamicOptic, DynamicValue, B) => Either[SchemaError, B]): Either[SchemaError, B]

Folds over the DynamicValue structure top-down, allowing failure.

Folds over the DynamicValue structure top-down, allowing failure.

Attributes

Source
DynamicValue.scala
def foldUp[B](z: B)(f: (DynamicOptic, DynamicValue, B) => B): B

Folds over the DynamicValue structure bottom-up. The function receives the current path, the DynamicValue, and the accumulator. Child values are folded before their parents.

Folds over the DynamicValue structure bottom-up. The function receives the current path, the DynamicValue, and the accumulator. Child values are folded before their parents.

Attributes

Source
DynamicValue.scala
def foldUpOrFail[B](z: B)(f: (DynamicOptic, DynamicValue, B) => Either[SchemaError, B]): Either[SchemaError, B]

Folds over the DynamicValue structure bottom-up, allowing failure.

Folds over the DynamicValue structure bottom-up, allowing failure.

Attributes

Source
DynamicValue.scala
def get(fieldName: String): DynamicValueSelection

Navigates to a field in a Record by name. Returns a DynamicValueSelection containing all matching values.

Navigates to a field in a Record by name. Returns a DynamicValueSelection containing all matching values.

Attributes

Source
DynamicValue.scala
def get(index: Int): DynamicValueSelection

Navigates to an element in a Sequence by index. Returns a DynamicValueSelection containing the value, or an error if index is out of bounds.

Navigates to an element in a Sequence by index. Returns a DynamicValueSelection containing the value, or an error if index is out of bounds.

Attributes

Source
DynamicValue.scala

Navigates to an entry in a Map by key. Returns a DynamicValueSelection containing all matching values.

Navigates to an entry in a Map by key. Returns a DynamicValueSelection containing all matching values.

Attributes

Source
DynamicValue.scala

Navigates to the value(s) at the given path. Returns a DynamicValueSelection that may contain zero or more values.

Navigates to the value(s) at the given path. Returns a DynamicValueSelection that may contain zero or more values.

Attributes

Source
DynamicValue.scala
def getCase(name: String): DynamicValueSelection

Navigates into a Variant case by name. Returns a DynamicValueSelection containing the case value if the case matches.

Navigates into a Variant case by name. Returns a DynamicValueSelection containing the case value if the case matches.

Attributes

Source
DynamicValue.scala

Inserts a value at the given path. If the path already exists, returns the original DynamicValue unchanged.

Inserts a value at the given path. If the path already exists, returns the original DynamicValue unchanged.

Attributes

Source
DynamicValue.scala

Inserts a value at the given path. Returns Left with an error if the path already exists or the parent doesn't exist.

Inserts a value at the given path. Returns Left with an error if the path already exists or the parent doesn't exist.

Attributes

Source
DynamicValue.scala
def is(t: DynamicValueType): Boolean

Returns true if this DynamicValue is of the specified type.

Returns true if this DynamicValue is of the specified type.

Attributes

Source
DynamicValue.scala

Merges this DynamicValue with another using the specified strategy.

Merges this DynamicValue with another using the specified strategy.

Attributes

Source
DynamicValue.scala

Modifies the value at the given path using a function. If the path doesn't exist, returns the original DynamicValue unchanged.

Modifies the value at the given path using a function. If the path doesn't exist, returns the original DynamicValue unchanged.

Attributes

Source
DynamicValue.scala
def modifyOrFail(path: DynamicOptic)(pf: PartialFunction[DynamicValue, DynamicValue]): Either[SchemaError, DynamicValue]

Modifies the value at the given path using a partial function. Returns Left with an error if the path doesn't exist or the partial function is not defined.

Modifies the value at the given path using a partial function. Returns Left with an error if the path doesn't exist or the partial function is not defined.

Attributes

Source
DynamicValue.scala

Applies sortFields, sortMapKeys, dropNulls, dropUnits, and dropEmpty.

Applies sortFields, sortMapKeys, dropNulls, dropUnits, and dropEmpty.

Attributes

Source
DynamicValue.scala

Partitions elements/fields based on a predicate on the value. Returns a tuple of (matching, non-matching) DynamicValues.

Partitions elements/fields based on a predicate on the value. Returns a tuple of (matching, non-matching) DynamicValues.

Attributes

Source
DynamicValue.scala

Partitions elements/fields based on a predicate on both path and value. Returns a tuple of (matching, non-matching) DynamicValues.

Partitions elements/fields based on a predicate on both path and value. Returns a tuple of (matching, non-matching) DynamicValues.

Attributes

Source
DynamicValue.scala

Partitions elements/fields based on a predicate on the path. Returns a tuple of (matching, non-matching) DynamicValues.

Partitions elements/fields based on a predicate on the path. Returns a tuple of (matching, non-matching) DynamicValues.

Attributes

Source
DynamicValue.scala

Returns the primitive value if this is a Primitive, otherwise None.

Returns the primitive value if this is a Primitive, otherwise None.

Attributes

Source
DynamicValue.scala

Projects only the specified paths from this DynamicValue. Creates a new DynamicValue containing only values at the given paths.

Projects only the specified paths from this DynamicValue. Creates a new DynamicValue containing only values at the given paths.

Attributes

Source
DynamicValue.scala
def prune(p: DynamicValue => Boolean): DynamicValue

Recursively removes elements/fields for which the predicate returns true.

Recursively removes elements/fields for which the predicate returns true.

Attributes

Source
DynamicValue.scala

Recursively removes elements/fields for which the predicate on both path and value returns true.

Recursively removes elements/fields for which the predicate on both path and value returns true.

Attributes

Source
DynamicValue.scala
def prunePath(p: DynamicOptic => Boolean): DynamicValue

Recursively removes elements/fields at paths for which the predicate returns true.

Recursively removes elements/fields at paths for which the predicate returns true.

Attributes

Source
DynamicValue.scala
def retain(p: DynamicValue => Boolean): DynamicValue

Recursively keeps only elements/fields for which the predicate returns true.

Recursively keeps only elements/fields for which the predicate returns true.

Attributes

Source
DynamicValue.scala

Recursively keeps only elements/fields for which the predicate on both path and value returns true.

Recursively keeps only elements/fields for which the predicate on both path and value returns true.

Attributes

Source
DynamicValue.scala
def retainPath(p: DynamicOptic => Boolean): DynamicValue

Recursively keeps only elements/fields at paths for which the predicate returns true.

Recursively keeps only elements/fields at paths for which the predicate returns true.

Attributes

Source
DynamicValue.scala

Wraps this DynamicValue in a DynamicValueSelection.

Wraps this DynamicValue in a DynamicValueSelection.

Attributes

Source
DynamicValue.scala

Wraps this DynamicValue in a DynamicValueSelection if its type matches the specified DynamicValueType, otherwise returns an empty selection.

Wraps this DynamicValue in a DynamicValueSelection if its type matches the specified DynamicValueType, otherwise returns an empty selection.

Attributes

Source
DynamicValue.scala

Sets a value at the given path. If the path doesn't exist, returns the original DynamicValue unchanged.

Sets a value at the given path. If the path doesn't exist, returns the original DynamicValue unchanged.

Attributes

Source
DynamicValue.scala

Sets a value at the given path. Returns Left with an error if the path doesn't exist.

Sets a value at the given path. Returns Left with an error if the path doesn't exist.

Attributes

Source
DynamicValue.scala

Recursively sorts all Record fields alphabetically.

Recursively sorts all Record fields alphabetically.

Attributes

Source
DynamicValue.scala

Recursively sorts all Map entries by key.

Recursively sorts all Map entries by key.

Attributes

Source
DynamicValue.scala
def toEjson(indent: Int = ...): String

Attributes

Source
DynamicValue.scala
def toJson: Json

Converts this DynamicValue to a Json value.

Converts this DynamicValue to a Json value.

Attributes

Source
DynamicValue.scala

Converts this DynamicValue to a Chunk of path-value pairs. Each pair contains the path to a leaf value and the value itself.

Converts this DynamicValue to a Chunk of path-value pairs. Each pair contains the path to a leaf value and the value itself.

Attributes

Source
DynamicValue.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
DynamicValue.scala

Transforms this DynamicValue top-down using the given function. The function receives the current path and the DynamicValue at that path. Parent values are transformed before their children.

Transforms this DynamicValue top-down using the given function. The function receives the current path and the DynamicValue at that path. Parent values are transformed before their children.

Attributes

Source
DynamicValue.scala
def transformFields(f: (DynamicOptic, String) => String): DynamicValue

Transforms all Record field names using the given function. The function receives the current path and the field name at that path.

Transforms all Record field names using the given function. The function receives the current path and the field name at that path.

Attributes

Source
DynamicValue.scala

Transforms all Map keys using the given function. The function receives the current path and the key at that path.

Transforms all Map keys using the given function. The function receives the current path and the key at that path.

Attributes

Source
DynamicValue.scala

Transforms this DynamicValue bottom-up using the given function. The function receives the current path and the DynamicValue at that path. Child values are transformed before their parents.

Transforms this DynamicValue bottom-up using the given function. The function receives the current path and the DynamicValue at that path. Child values are transformed before their parents.

Attributes

Source
DynamicValue.scala
def unwrap(t: DynamicValueType): Option[t.Unwrap]

Extracts the underlying value from this DynamicValue if it matches the specified type.

Extracts the underlying value from this DynamicValue if it matches the specified type.

Attributes

Source
DynamicValue.scala