ninny-json

JSON typeclasses that know the difference between null and absent fields

View the Project on GitHub nrktkt/ninny-json

Maven Central coverage
Gitter Matrix

Integrations

Reading values from JSON

Writing values to JSON

obj and arr build JSON structures

note: The above example uses magnets to produce an object building syntax similar to how you’d build a scala.collection.Map. This is intuitive, but can produce unhelpful compiler errors. Instead, you can use a “long arrow” --> or “squiggly arrow” ~> to get better compiler errors for debugging, or just because you don’t like magnets. See below for an example

Updating nested values

With immutable ASTs it can be a pain to update values deep inside the tree.
You can use ninny’s dynamic update syntax easly to replace values way down in there.

Converting domain objects to JSON

Converting JSON to domain objects

Automatic derivation for ToJson and FromJson

Rather than implementing ToJson and FromJson by hand, you can generate them automatically using

See more on configuring automatic derivation here.

forProductN derivation for ToJson and FromJson

Often you want to have different names in a case class than what’s in the JSON, but you don’t need to change the types at all. forProductN methods are perfect for this, just specify what the JSON field name should be and provide the case class apply/unapply method to generate a ToJson, FromJson, or both together.