A Schema[A] describes the structure of the type A, such as the fields of a case class or the cases of a sealed trait, together with the functions that build and take apart values of A. Derive one with Schema.derived, then use it to get codecs for formats such as JSON, convert values to and from DynamicValue, compute and apply patches, and attach documentation, examples and default values.
A schema is an immutable value: methods such as doc, defaultValue and modifier return a new schema. It wraps a Reflect.Bound[A], which holds the structure and its bindings.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Schema[Book].jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val value = Schema[Book].toDynamicValue(Book("Zionomicon", 2021))
// {
// title: "Zionomicon",
// year: 2021
// }
Attributes
- See also
- Companion
- object
- Source
- Schema.scala
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait SchemaVersionSpecific[A]class Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns a schema with aspect applied to the whole structure of A.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema with aspect applied to the part of A that part focuses on. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
Decodes a value of A from decodeInput with the codec of format, the one getInstance returns, and returns Left when the input does not decode.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val input = ByteBuffer.wrap("""{"title":"Zionomicon","year":2021}""".getBytes(StandardCharsets.UTF_8))
val book = Book.schema.decode(JsonFormat)(input) // Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the default value value. When the optic does not resolve against this schema, this schema is returned unchanged.
case class Book(title: String, year: Int = 2021)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val year: Lens[Book, Int] = $(_.year)
}
val declared = Book.schema.getDefaultValue(Book.year) // Some(2021)
val updated = Book.schema.defaultValue(Book.year, 2024).getDefaultValue(Book.year) // Some(2024)
Attributes
- See also
- Source
- Schema.scala
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Returns a schema whose default value for A is value, the value that getDefaultValue then returns.
Attributes
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
Derives an instance of the type class TC for A with d: a Deriver[TC], or a format such as JsonFormat, whose default deriver is then used. Unlike getInstance, each call derives a new instance, so keep the result, for example in an implicit val.
import zio.blocks.schema.json.{JsonCodec, JsonCodecDeriver, JsonFormat}
case class Book(title: String, publishedIn: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val default: JsonCodec[Book] = Book.schema.derive(JsonFormat)
val snakeCase: JsonCodec[Book] = Book.schema.derive(JsonCodecDeriver.withFieldNameMapper(NameMapper.SnakeCase))
val json = snakeCase.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","published_in":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
Starts a derivation of TC for A with deriver, which you can customize before calling derive on the result: override the instance used for a field, a case or a type, or add modifiers, without changing this schema. The result is not cached.
When deriver already has a withInstance override for a type, that override wins over one given for the same type with DerivationBuilder#instance.
import zio.blocks.schema.json.JsonCodecDeriver
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val codec = Book.schema
.deriving(JsonCodecDeriver)
.modifier(Book.title, Modifier.rename("name"))
.derive
val json = codec.encodeToString(Book("Zionomicon", 2021)) // {"name":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Computes a patch that turns oldValue into newValue, by comparing the DynamicValue forms of the two values.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Returns the documentation of A stored in this schema, or Doc.empty when there is none.
Attributes
- Source
- Schema.scala
Returns a schema whose documentation is value, replacing any documentation it had.
Returns a schema whose documentation is value, replacing any documentation it had.
case class Book(title: String, year: Int)
object Book extends CompanionOptics[Book] {
implicit val schema: Schema[Book] = Schema.derived
val title: Lens[Book, String] = $(_.title)
}
val documented = Book.schema
.doc("A book in the catalogue")
.doc(Book.title, "The title on the cover")
val bookDoc = documented.doc.toString.trim // A book in the catalogue
val titleDoc = documented.doc(Book.title).toString.trim // The title on the cover
Attributes
- See also
- Source
- Schema.scala
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Returns the documentation of the part of A that optic focuses on, or Doc.empty when the optic does not resolve or the part has none.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the documentation value. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Encodes value into output with the codec of format, the one getInstance returns.
Encodes value into output with the codec of format, the one getInstance returns.
import java.nio.ByteBuffer
import java.nio.charset.StandardCharsets
import zio.blocks.schema.json.JsonFormat
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val buffer = ByteBuffer.allocate(256)
Book.schema.encode(JsonFormat)(buffer)(Book("Zionomicon", 2021))
buffer.flip()
val json = StandardCharsets.UTF_8.decode(buffer).toString // {"title":"Zionomicon","year":2021}
Attributes
- See also
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Returns the example values of A stored in this schema.
Returns a schema whose examples are value and values, replacing any examples it had.
Returns a schema whose examples are value and values, replacing any examples it had.
Attributes
- Source
- Schema.scala
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Returns the examples of the part of A that optic focuses on, or an empty Seq when the optic does not resolve.
Attributes
- Source
- Schema.scala
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Returns a schema in which the part of A that optic focuses on has the examples value and values. When the optic does not resolve against this schema, this schema is returned unchanged.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Converts value to a value of A. Returns Left when value does not match this schema, with the failures of all record fields collected in one SchemaError, or when a transform function throws.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns the structure of the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns the structure of the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Returns the default value of A set with defaultValue, or None when there is none. A derived schema stores the defaults of case class fields on the fields, not on the record: read them with the overload that takes an optic.
Attributes
- Source
- Schema.scala
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Returns the default value of the part of A that optic focuses on, such as the default of a case class field, or None when the optic does not resolve or the part has no default.
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
Returns the codec of format for A. The first call derives it with the format's default deriver, format.deriver; later calls with the same format return the cached instance.
The cache belongs to this Schema value, so a schema returned by doc, modifier or any other update derives its codec again.
import zio.blocks.schema.json.{JsonCodec, JsonFormat}
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val codec: JsonCodec[Book] = Book.schema.getInstance(JsonFormat)
val cached = codec eq Book.schema.getInstance(JsonFormat) // true
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifier added after the modifiers that A already has.
Returns a schema with modifier added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Returns a schema with modifiers added after the modifiers that A already has.
Returns a schema with modifiers added after the modifiers that A already has.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Applies patch to value in strict mode: returns Left when an operation of the patch cannot be applied, or when the result does not convert back to A.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Converts this schema to a DynamicSchema by dropping its bindings. The result keeps the structure (fields, cases, types and Validation constraints) but cannot build values of A; use it to check DynamicValue instances against the structure.
Its check does not run the checks of transform functions, because they live in the bindings it drops.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Converts value to a DynamicValue that follows this schema. An exception thrown by the from function of a transform on the way propagates to the caller.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.scala
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Derives a JSON Schema from this schema. Validation constraints are not included in it.
Attributes
- Source
- Schema.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
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
Returns a schema for B that represents each B as the A that from returns. Use it for wrapper types, newtypes and validated types. The implicit TypeId[B] gives the new schema its type name.
to runs when a value is decoded, by a codec or by fromDynamicValue, and may throw to reject the value, for example with SchemaError.validationFailed. The decoder then returns Left with the message of the exception at a path that ends in .wrapped, the step into the wrapped A. from runs when a value is encoded or converted with toDynamicValue, and neither catches an exception it throws: toDynamicValue rethrows it unchanged, and the JSON codec throws it as a JsonCodecError that keeps its message.
DynamicSchema#check does not run the checks in to.
final case class PageCount(value: Int)
object PageCount {
implicit val schema: Schema[PageCount] = Schema[Int].transform(
n => if (n > 0) PageCount(n) else throw SchemaError.validationFailed("page count must be positive, got " + n),
_.value
)
}
val pages = "816".fromJson[PageCount] // Right(PageCount(816))
val invalid = "-5".fromJson[PageCount]
// Left(zio.blocks.schema.SchemaError: page count must be positive, got -5 at: .wrapped)
Attributes
- See also
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Returns a schema in which f has rewritten the part of A at the path dynamic, or None when the path does not resolve against this schema.
Attributes
- Source
- Schema.scala
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Returns a schema in which f has rewritten the part of A that optic focuses on, or None when the optic does not resolve against this schema.
Attributes
- Source
- Schema.scala
Inherited methods
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
- Source
- Product.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
Converts this schema to a schema of the structural type of A: a refinement with one member per field, such as { def title: String; def year: Int } for case class Book(title: String, year: Int). Use it to work with values by their shape rather than by their nominal type.
On Scala 3 the result has the structural type. On Scala 2 its static type is Schema[ts.StructuralType]: the compiler does not see the refinement, so the result cannot be assigned to a Schema of the structural type.
The conversion is available on the JVM only, because structural types need reflection.
case class Book(title: String, year: Int)
val structural = Schema.derived[Book].structural
Value parameters
- ts
-
the macro-generated conversion to the structural type
Attributes
- See also
- Inherited from:
- SchemaVersionSpecific
- Source
- SchemaVersionSpecific.scala
Concrete fields
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
The JSON codec of A, derived on first use with the default JSON deriver and cached. It is the instance that getInstance(JsonFormat) returns.
Derivation reads only the schema, so this codec ignores an implicit JsonCodec in scope and the overrides of a configured deriver, such as JsonCodecDeriver.withInstance. To use a configured deriver, derive the codec with derive or deriving and call that codec directly: the toJsonString and fromJson syntax always uses this one.
case class Book(title: String, year: Int)
object Book {
implicit val schema: Schema[Book] = Schema.derived
}
val json = Book.schema.jsonCodec.encodeToString(Book("Zionomicon", 2021))
// {"title":"Zionomicon","year":2021}
val book = Book.schema.jsonCodec.decode("""{"title":"Zionomicon","year":2021}""")
// Right(Book(Zionomicon,2021))
Attributes
- See also
- Source
- Schema.scala