org.sigilaris.core.codec.json.JsonEncoder
See theJsonEncoder companion object
Type class for encoding Scala values into the core JsonValue AST.
Encoders consult a JsonConfig to honor naming policies, null/absent handling, discriminator strategy, and number formatting for big numbers.
Use contramap to adapt existing encoders and derived to auto-derive for products and sums when appropriate givens are in scope.
Attributes
- See also
-
JsonDecoder for the inverse operation
JsonCodec for bidirectional encoding and decoding
JsonConfig for configuration options
- Note
-
Encoding is deterministic: the same value always produces the same JSON structure. However, object field order may vary. Use sorted encoding if field order matters.
- Example
-
case class User(name: String, age: Int) derives JsonEncoder val user = User("Alice", 30) val json = JsonEncoder[User].encode(user) - Companion
- object
- Source
- JsonEncoder.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
JsonEncoder[A]
Members list
In this article