- Akka HTTP
- blackdoor jose
- mercury JSON-RPC
- Play JSON (if you find something with Play support, it will work with ninny too!)
If you're reading this, you should go to the userguide website at https://nrktkt.github.io/ninny-json/USERGUIDE
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/Reading.scala' lines='8:63'
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala' lines='9:23'
obj
and arr
build JSON structures
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala' lines='25:47'
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
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala' lines='52:74'
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.
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/Updating.scala' lines='5:18'
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/DomainTo.scala' lines='7:51'
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/DomainFrom.scala' lines='22:49'
Rather than implementing ToJson
and FromJson
by hand, you can generate them
automatically using
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/SemiAuto.scala' lines='11:16'
See more on configuring automatic derivation here.
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.
<sauce-code repo='nrktkt/ninny-json' lang='scala' file='ninny/test/src-2/nrktkt/ninny/userguide/ForProductN.scala' lines='8:24'