kmizu / nson

NSON: an object notation that is not a JSON but alike JSON.

GitHub

NSON: an object notation that is not a JSON but alike JSON

Gitter Build Status Maven Central Scaladoc Reference Status

NSON is a new object notation like JSON and unlike JSON. NSON is strict superset of JSON and differ from JSON in that NSON doesn't require any comma as a separator character.

For example, the following example, including several properties of an object, doesn't have any comma:

{"name": "Kota Mizushima" "age": 33
  "like" : ["Scala" "Haskell" "Nemerle" "Rust"]}

Usage

Add the following lines to your build.sbt file:

libraryDependencies += "com.github.kmizu" %% "nson" % "0.0.2"

Then, you can use NValueParser as the followings:

import com.github.kmizu.nson.NValueParser
val nvalue = NValuePaser.parse(
  """
  | {x: 1 y: 2}
  """.stripMargin
)
println(nvalue.x.value) // => 1
println(nvalue.y.value) // => 2

Syntax

Integer

64-bit signed integer.

10
20
0x10 // 16
-20  // -20

Floating Point Number

IEEE 754 double precision floating point number

1.0
1.5
2.0
3.0

Boolean

true
false

String

""
"Hello, World"
"Foo"
"Bar"

Array

[]
[1, 2, 3]
[1 2 3] //comma is omitted
[1
 2
 3] // line feed is also separator

Object

{"x" : 1, "y": 2}
{ x : 1 y : 2} //comma is omitted
{"x"1"y"2} // colon is omitted
{"x" : 1
 "y" : 2} // line feed is also separator
{ x : 1, y : 2} // identifier
{ x : 1  y : 2}