kmizu / jsonda

A DSL for constructing json-like data sturctures

Website GitHub

Jsonda - Simple DSL for JSON objects which is independent from specific JSON library Build Status

This project provides a Jsonda DSL, which can be used to construct JSON object easily, in Scala. The code size of Jsonda is small and it is easy to understand what it does. Although Jsonda was formerly Jsonic, I was told that there is already another Jsonic library in Java by @okapies san. Then, I renamed Jsonic to Jsonda.

Using with sbt

If you woule like to use Jsonda with sbt, what you need to do is only adding the following lines to your build.sbt. There exists jsonda 1.6.0 for Scala.2.11.X and Scala 2.12.X.

For jsonda-json4s:

libraryDependencies += "com.github.kmizu" %% "jsonda" % "1.6.0"

For jsonda-play_json:

libraryDependencies += "com.github.kmizu" %% "jsonda" % "1.6.0"

Release Note


  • Drop spray-json support
  • Add support for play-json


  • Drop Scala 2.9.X and Scala 2.10.X support
  • Add support for spray-json


  • Drop std-json and lif-json support. The reason why lift-json support is dropped is that lift-json against Scala 2.11 was not published.


Jsonda is very simple DSL for creating JSON objects. Notations are followings:

  • object:

scala %{ $key1 :- $value1; $key2 :- $value2; ... }

available from 1.0.0
    %{ $key1 := $value1; $key2 := $value2; ... }


scala %{ $key1 :- $value1 $key2 :- $value2 }

available from 1.0.0
    %{ $key1 := $value1
       $key2 := $value2 }

Both have same meanings.

  • array:

scala $($value1, $value2, ...)

or Traversable[JsonValueType] as the followings (new in jsonda 0.8.0):

    Seq($value1, $value2, ...)
  • primitive:
    • number(Int):

scala 100 200 300

  * number (Long)

  • number(Float): ```scala`` 10.5F 12.0F

  * number(Double):

  • string (from Scala's BigInt):

scala BigInt("100000000000000000000") BigInt("2000000000000000000000000")

  * string (from Scala's BigDecimal):

  • string:

scala "Hello, World!" "Hello, Scala!"

  * boolean:

  • null:

scala JsonNull

  * Option[A]:
    If value of Option[A] is Some(a), a is implicitly converted.  None is regarded as null in JSON.

# Quick Start

Here are the way to create JSON using Jsonda (with jsonda-json4s):

import com.github.kmizu.jsonda.dsl.Json4sDSL._

val person = %{
  'name :- "Kota Mizushima"
  'age :- 33

The type of person is org.json4s.native.JValue. If you are familiar with json4s, you can easily manipulate JSON objects.

Or the below (with jsonda-play_json):

import com.github.kmizu.jsonda.dsl.PlayJsonDSL._

val person = %{
  'name :- "Kota Mizushima"
  'age :- 33

The type of person is play.api.libs.json.JsValue. If you are familiar with play-json you can easily manipulate JSON objects.

Nested JSON can be written easily as the followings:

import com.github.kmizu.jsonda.dsl.Json4sDSL._
val config = % {
  'name :- "a config"
  'debug :- false
  'logging :- % {
    'level :- "warn"
    'verbose :- true
  'optimization :- %{
    'agressive :- true
    'inline :- true


Scaladoc is available via the following links:


This software is distributed under modified BSD License. See LICENSE.txt