SyntaxVersionSpecific
Extension methods on values with a Schema, on JSON strings and on JSON bytes, available through import zio.blocks.schema._.
Attributes
- See also
- Source
- syntax.scala
- Graph
-
- Supertypes
Members list
Extensions
Extensions
Applies patch to this value in lenient mode: operations that cannot be applied are skipped, and when the result does not convert back to A, this value is returned unchanged.
Applies patch to this value in lenient mode: operations that cannot be applied are skipped, and when the result does not convert back to A, this value is returned unchanged.
Attributes
- Source
- syntax.scala
Applies patch to this value in strict mode, returning Left when an operation of the patch cannot be applied.
Applies patch to this value in strict mode, returning Left when an operation of the patch cannot be applied.
Attributes
- Source
- syntax.scala
Computes the patch that turns this value into that, as Schema#diff does.
Computes the patch that turns this value into that, as Schema#diff does.
Attributes
- Source
- syntax.scala
Renders this value as its DynamicValue, in the JSON-like EJSON text form with unquoted record keys.
Renders this value as its DynamicValue, in the JSON-like EJSON text form with unquoted record keys.
Attributes
- Source
- syntax.scala
Encodes this value to a Json value with Schema#jsonCodec.
Encodes this value to UTF-8 JSON bytes with Schema#jsonCodec.
Encodes this value to a JSON string with Schema#jsonCodec, the codec derived with the default JSON deriver.
Encodes this value to a JSON string with Schema#jsonCodec, the codec derived with the default JSON deriver.
It ignores an implicit JsonCodec in scope and any deriver configured with withInstance or withModifier: to use such a deriver, derive the codec with Schema#derive and call encodeToString on it. An implicit Schema of a field type, by contrast, is used by Schema.derived.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book("Zionomicon", 2021).toJsonString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- syntax.scala
Decodes a value of A from this JSON string with Schema#jsonCodec, returning Left with a SchemaError when the JSON is malformed or does not match the schema. Like toJsonString, it ignores implicit codecs and configured derivers.
Decodes a value of A from this JSON string with Schema#jsonCodec, returning Left with a SchemaError when the JSON is malformed or does not match the schema. Like toJsonString, it ignores implicit codecs and configured derivers.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val book = """{"title":"Zionomicon","year":2021}""".fromJson[Book] // Right(Book(Zionomicon,2021))
val missing = """{"year":2021}""".fromJson[Book]
// Left(zio.blocks.schema.SchemaError: missing required field "title" at: .)
Attributes
- See also
- Source
- syntax.scala
Decodes a value of A from these UTF-8 JSON bytes with Schema#jsonCodec, returning Left with a SchemaError when the JSON is malformed or does not match the schema.
Decodes a value of A from these UTF-8 JSON bytes with Schema#jsonCodec, returning Left with a SchemaError when the JSON is malformed or does not match the schema.
Attributes
- Source
- syntax.scala