play-jsonminify is a JSON 'compiled asset plugin' for Play 2.0 based on JSON.simple.
It is similar to the other built-in compilers. JSON files placed under
app/assets will be transformed into a pretty-printed and a compressed version.
For example, JSON in
will be automatically compiled into a pretty-printed version, when requested via
and a compressed version when requested via
Compile time errors (such as unclosed brackets or unexpected characters) will cause a nice Play error page:
As you can see on line 3, leaving out commas is not necessarily breaking the compiler. As well as unnecessary trailing commas will be stripped automatically. (thanks to JSON.simple).
Add the plugin and the repository to your application's
resolvers += "Play JSONminify repository" at "http://joscha.github.com/play-jsonminify/repo/" addSbtPlugin("com.feth" % "play-jsonminify" % "0.1.0")
This adds the JSON asset compiler to your Play project.
*.json files beneath
will then be automatically compiled to
*.min.json files. Files starting with
_-character will be left out from compilation as per Play convention.
First you must publish the plugin to your Play 2.0 repository. You will have to specify your top level play directory and the version:
sbt -Dplay.path=../play-2.0.1 -Dplay.version=2.0.1 publish
Then add the plugin to your application's
addSbtPlugin("com.feth" % "play-jsonminify" % "0.1.0")
To override the default settings, you can add the following lines to the
this would for example also process JSON files starting with the
jsonminifyEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.json")
- 0.1.0 [2012-05-18] Initial release
Copyright (c) 2012 Joscha Feth
MIT-style license, see details from LICENSE file.