SkillAgentSearch skills...

Jsonv

A scala DSL for validating JSON using the Json4s AST and scalaz Validation

Install / Use

/learn @Astrac/Jsonv
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Jsonv

A library that provides the following:

  • A simple and extensible DSL to create JSON validators based on the Json4s AST and on scalaz Validation
  • A Json4s serializer that can serialize and de-serialize scalaz Validation instances

Quick example

From tests:

val json = parse("""{ "foo": 1, "bar": { "baz": true, "qux": [ 1, 2, 3 ] }, "quz": "blag", "dub": 1.2 }""")

val validator = valid[JObject] <~ props(
  _("foo")[JInt],
  _("bar")[JObject] <~ props(
    _("baz")[JBool],
    _("qux")[JArray]
  ),
  _("quz")[JString],
  _("dub")[JDouble]
)

validator(json) should equal(Success(json))

For examples of usage please refer to tests.

TODO

Things that I would like to add:

  • More validation predicates
  • Support for building the base validator from a case class (if possible)
  • More documentation
View on GitHub
GitHub Stars8
CategoryDevelopment
Updated5mo ago
Forks0

Languages

Scala

Security Score

82/100

Audited on Oct 17, 2025

No findings