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:
- DynamicValue.Primitive - Scalar values (strings, numbers, booleans, temporal types, etc.)
- DynamicValue.Record - Named fields, analogous to case classes or JSON objects
- DynamicValue.Variant - Tagged unions, analogous to sealed traits
- DynamicValue.Sequence - Ordered collections (lists, arrays, vectors)
- DynamicValue.Map - Key-value pairs where keys are also DynamicValues
- DynamicValue.Null - Represents absence of a value
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
- Known subtypes
Members list
Value members
Abstract methods
Attributes
- Source
- DynamicValue.scala
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.
Concrete methods
Attributes
- Source
- DynamicValue.scala
Attributes
- Source
- DynamicValue.scala
Attributes
- Source
- DynamicValue.scala
Attributes
- Source
- DynamicValue.scala
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
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
Returns the case name if this is a Variant, otherwise None.
Returns the case value if this is a Variant, otherwise None.
Validates this value against a DynamicSchema.
Validates this value against a DynamicSchema.
Value parameters
- schema
-
The schema to validate against
Attributes
- Returns
-
Noneif this value conforms to the schema, orSome(SchemaError)describing the validation failure - See also
-
DynamicSchema.check for the underlying validation logic
- Source
- DynamicValue.scala
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
-
trueif this value passes all validation checks,falseotherwise - 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 all Null values from containers.
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
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
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
Folds over the DynamicValue structure top-down, allowing failure.
Folds over the DynamicValue structure top-down, allowing failure.
Attributes
- Source
- DynamicValue.scala
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
Folds over the DynamicValue structure bottom-up, allowing failure.
Folds over the DynamicValue structure bottom-up, allowing failure.
Attributes
- Source
- DynamicValue.scala
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
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
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
Returns true if this DynamicValue is of the specified type.
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
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
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
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
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
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 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 Map entries by key.
Attributes
- Source
- DynamicValue.scala
Converts this DynamicValue to a Json value.
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
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
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
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