Skip to content

isabella232/minify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Minify

A simple Java utility for minifying JSON code in your Java application.

Overview

This library is built for use with Java applications for the purpose of minifying JSON code. This work is an adaptation of JSMin.java written by John Reilly (www.inconspicuous.org) which is itself a translation of jsmin.c written by Douglas Crockford (www.crockford.com).

Reference

Minify has a simple utility method for producing minified JSON:

/**
 * Minifies the input JSON string.
 * 
 * Takes the input JSON string and deletes the characters which are insignificant to JavaScipt.  Comments will
 * be removed, tabs will be replaced with spaces, carriage returns will be replaced with line feeds, and most
 * spaces and line feeds will be removed.  The result will be returned.
 * 
 * @param json The JSON string for which to minify
 * @return A minified, yet functionally identical, version of the input JSON string
 */ 
public String minify(String json)

Note: Minify also has a second utility method for producing minified JSON from a stream of input, if you'd like to work directly with streams.

Usage

To use the library, simply instantiate an instance of the Minify class and invoke one of the minify() utility methods:

String minifiedJson = new Minify().minify(unminifiedJson);

Author

Relevant

License

Permission is hereby granted to use this Java version under the same conditions as the original jsmin.c on which all of these derivatives are based. See the header on Minify.java for more.

About

Minify JSON from your Java project

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%