https://github.com/joscha/play-jsonminify
A JSON minification plugin / asset compiler for the Play! Framework
https://github.com/joscha/play-jsonminify
Last synced: 8 months ago
JSON representation
A JSON minification plugin / asset compiler for the Play! Framework
- Host: GitHub
- URL: https://github.com/joscha/play-jsonminify
- Owner: joscha
- License: mit
- Archived: true
- Created: 2012-05-18T13:34:58.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-06-14T21:13:30.000Z (over 13 years ago)
- Last Synced: 2025-05-07T11:18:00.682Z (8 months ago)
- Language: Scala
- Size: 371 KB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# play-jsonminify - JSON minification compiler for Play 2.0
## About
This plugin is initially based on [Ray][] and [play-stylus][].
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 `app/assets/javascripts/xyz.json`

will be automatically compiled into a pretty-printed version, when requested via
`public/javascripts/xyz.json`:

and a compressed version when requested via `public/javascripts/xyz.min.json`:

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][]).
## Installation
Add the plugin and the repository to your application's `project/plugins.sbt`:
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 `app/assets`
will then be automatically compiled to `*.json` and `*.min.json` files. Files starting with
`_`-character will be left out from compilation as per Play convention.
## Installation (build from source)
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 `project/plugins.sbt`:
addSbtPlugin("com.feth" % "play-jsonminify" % "0.1.0")
### Settings
To override the default settings, you can add the following lines to the `settings` call
in your `Build.scala` (examples):
this would for example also process JSON files starting with the `_`-character:
jsonminifyEntryPoints <<= (sourceDirectory in Compile)(base => base / "assets" ** "*.json")
## Versions
* *0.1.0* [2012-05-18] Initial release
## License
Copyright (c) 2012 Joscha Feth
MIT-style license, see details from LICENSE file.
[Ray]: http://github.com/pufuwozu/ray
[play-stylus]: http://raw.github.com/knuton/play-stylus
[JSON]: http://www.json.org
[JSON.simple]: http://code.google.com/p/json-simple/