Package org.restheart.utils
Class Minify
java.lang.Object
org.restheart.utils.Minify
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classException to be thrown when an unterminated comment appears in the input.static classException to be thrown when an unterminated regular expression literal appears in the input.static classException to be thrown when an unterminated string literal appears in the input. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidminify(InputStream in, OutputStream out) Takes an input stream to a JSON string and outputs minified JSON to the output stream.Minifies the input JSON string.
-
Constructor Details
-
Minify
public Minify()
-
-
Method Details
-
minify
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.- Parameters:
json- The JSON string for which to minify- Returns:
- A minified, yet functionally identical, version of the input JSON string
-
minify
public void minify(InputStream in, OutputStream out) throws IOException, Minify.UnterminatedRegExpLiteralException, Minify.UnterminatedCommentException, Minify.UnterminatedStringLiteralException Takes an input stream to a JSON string and outputs minified JSON to the output stream. Takes the input JSON via the input stream and deletes the characters which are insignificant to JavaScript. Comments will be removed, tabs will be replaced with spaaces, carriage returns will be replaced with line feeds, and most spaces and line feeds will be removed. The result is streamed to the output stream.- Parameters:
in- TheInputStreamfrom which to get the un-minified JSONout- TheOutputStreamwhere the resulting minified JSON will be streamed to- Throws:
IOExceptionMinify.UnterminatedRegExpLiteralExceptionMinify.UnterminatedCommentExceptionMinify.UnterminatedStringLiteralException
-