jtownley/Scala-Json-Generator
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Copyright 2010-2011 - Chris Tarttelin & James Townley
Release under Apache-BSD style License
Version: 0.6.0
----------------------------------
Description
----------------------------------
A lightweight tool for templating Json in Scala
----------------------------------
Usage
----------------------------------
Best explained by example and by looking at tests.
Example:
val obj = jsonObject() {
field("Store", Some("Bob's Fromagery"))
jsonObject("Address") {
field("Suite", Some("1"))
field("Number", Some("21b"))
field("Name", Some("Baker Street"))
}
jsonArray("Cheeses") {
value(Some("Munster"))
value(Some("Brie"))
value(Some("Cheddar"))
}
}
println(obj.asString)
Result:
{"Store":"Bob's Fromagery","Address":{"Suite":"1","Number":"21b","Name":"Baker Street"},"Cheeses":["Munster","Brie","Cheddar"]}
Changes:
Version 0.3 -
Now runs with Scala 2.8
Version 0.5.x -
- Made it thread safe
- Now escaping of linefeed type characters
- Chose collections that are common between 2.7 and 2.8
- Added a build.xml. To build, you will need to include the appropriate scala-compiler.jar and scala-library.jar and amend the classpath in the ant file accordingly.
- Fixed bug with null array values being treated as "null" strings
- Added option for None values to produce same effect as Some(null)
Version 0.6.0
- Fixed bug where an empty jsonObject in a jsonArray is not return Array:null when OMIT_NONE_FIELDS = false