JsonMatch
zio.blocks.schema.json.JsonMatch
object JsonMatch
Provides matching logic for SchemaRepr patterns against Json instances.
This object implements structural pattern matching between schema representations and JSON values, enabling the search optic to find JSON values that match a given schema pattern.
==Matching Rules==
- '''Wildcard''': Matches any Json value
- '''Primitive(name)''': Matches Json primitive types:
- "string" matches Json.String
- "boolean" matches Json.Boolean
- "int", "long", "short", "byte", "float", "double", "number", "bigint", "bigdecimal" all match Json.Number
- "null" matches Json.Null
- '''Record(fields)''': Matches Json.Object using subset matching - all specified fields must exist with matching types, but extra fields are allowed
- '''Variant(cases)''': Returns false (JSON doesn't have tagged variants)
- '''Sequence(elem)''': Matches Json.Array if all elements match the element pattern (empty array always matches)
- '''Map(k, v)''': Matches Json.Object if key pattern is "string" and all values match the value pattern (empty object always matches)
- '''Optional(inner)''': Matches Json.Null always, otherwise checks inner pattern
- '''Nominal(name)''': Returns false (requires schema context not available in JSON)
Attributes
- Source
- JsonMatch.scala
- Graph
-
- Supertypes
- Self type
-
JsonMatch.type
Members list
In this article