public class JsonWriter
extends java.lang.Object
Constructor | Description |
---|---|
JsonWriter() |
Constructor with default properties.
|
JsonWriter(int indent,
boolean spacer) |
Custom constructor.
|
Modifier and Type | Method | Description |
---|---|---|
java.lang.String |
getIndent(int level) |
Returns prepended whitespace.
|
java.lang.String |
jsonPair(java.lang.String key,
java.lang.Object value,
int level,
boolean isPositioned) |
Serialises a key-value pair to JSON.
|
java.lang.String |
toJson(java.lang.Object item) |
Converts an item to JSON.
|
void |
toJson(java.lang.StringBuffer sbuf,
java.lang.Object item,
int level,
boolean isPositioned) |
Recursive method which does the work for conversion.
|
public JsonWriter()
public JsonWriter(int indent, boolean spacer)
indent
- number of characters indent per levelspacer
- whether to put spaces inside bracketspublic java.lang.String toJson(java.lang.Object item)
item
- suitable objectpublic void toJson(java.lang.StringBuffer sbuf, java.lang.Object item, int level, boolean isPositioned)
isPositioned=false
.sbuf
- string buffer to append result toitem
- object to convertlevel
- current indentation levelisPositioned
- true if output should be direct to sbuf,
false if it needs a newline plus indentation firstpublic java.lang.String getIndent(int level)
level
- indentation levelpublic java.lang.String jsonPair(java.lang.String key, java.lang.Object value, int level, boolean isPositioned)
key
- key stringvalue
- value objectlevel
- indentation levelisPositioned
- true if output should be direct to sbuf,
false if it needs a newline plus indentation firstCopyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.