Package org.apache.tapestry5.json
Class JSONCollection
java.lang.Object
org.apache.tapestry5.json.JSONCollection
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JSONArray
,JSONObject
Base class for
JSONArray
and JSONObject
that exists to organize the code
for printing such objects (either compact or pretty).- Since:
- 5.2.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
prettyPrint
(PrintWriter writer) Prints the JSONObject to the writer using indentation (two spaces per indentation level).void
print
(PrintWriter writer) Prints the JSONObject to the writer compactly (with no extra whitespace).void
print
(PrintWriter writer, boolean compact) Prints the JSONObject to the write (compactly or not).Prints the JSONObject as a compact string (not extra punctuation).toString()
Converts this JSON collection into a parsable string representation.toString
(boolean compact) Converts the JSONObject to a compact or pretty-print string representation
-
Constructor Details
-
JSONCollection
public JSONCollection()
-
-
Method Details
-
toString
Converts this JSON collection into a parsable string representation. Warning: This method assumes that the data structure is acyclical. Starting in release 5.2, the result will be pretty printed for readability. -
toString
Converts the JSONObject to a compact or pretty-print string representation- Parameters:
compact
- if true, return minimal format string.- Since:
- 5.2.0
-
toCompactString
Prints the JSONObject as a compact string (not extra punctuation). This is, essentially, what Tapestry 5.1 did insidetoString()
. -
print
Prints the JSONObject to the write (compactly or not).- Parameters:
writer
- to write content tocompact
- if true, then write compactly, if false, write with pretty printing- Since:
- 5.2.1
-
print
Prints the JSONObject to the writer compactly (with no extra whitespace). -
prettyPrint
Prints the JSONObject to the writer using indentation (two spaces per indentation level).
-