Package com.yahoo.text
Class JSONWriter
- java.lang.Object
-
- com.yahoo.text.JSONWriter
-
public final class JSONWriter extends Object
A class which knows how to write JSON markup. All methods return this to enable chaining of method calls. Consider using the Jackson generator API instead, as that may be faster.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description JSONWriter(OutputStream stream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSONWriter
beginArray()
Begin an array valueJSONWriter
beginArrayValue()
Begins an array valueJSONWriter
beginField(String fieldName)
Begins an object fieldJSONWriter
beginObject()
Begin an object valueJSONWriter
endArray()
End an array valueJSONWriter
endArrayValue()
Ends an array valueJSONWriter
endField()
Ends an object fieldJSONWriter
endObject()
End an object valueJSONWriter
value()
Writes a null valueJSONWriter
value(boolean value)
Writes a boolean valueJSONWriter
value(Number value)
Writes a numeric valueJSONWriter
value(String value)
Writes a string value
-
-
-
Constructor Detail
-
JSONWriter
public JSONWriter(OutputStream stream)
-
-
Method Detail
-
beginField
public JSONWriter beginField(String fieldName) throws IOException
Begins an object field- Throws:
IOException
-
endField
public JSONWriter endField() throws IOException
Ends an object field- Throws:
IOException
-
beginArrayValue
public JSONWriter beginArrayValue() throws IOException
Begins an array value- Throws:
IOException
-
endArrayValue
public JSONWriter endArrayValue() throws IOException
Ends an array value- Throws:
IOException
-
beginObject
public JSONWriter beginObject() throws IOException
Begin an object value- Throws:
IOException
-
endObject
public JSONWriter endObject() throws IOException
End an object value- Throws:
IOException
-
beginArray
public JSONWriter beginArray() throws IOException
Begin an array value- Throws:
IOException
-
endArray
public JSONWriter endArray() throws IOException
End an array value- Throws:
IOException
-
value
public JSONWriter value(String value) throws IOException
Writes a string value- Throws:
IOException
-
value
public JSONWriter value(Number value) throws IOException
Writes a numeric value- Throws:
IOException
-
value
public JSONWriter value(boolean value) throws IOException
Writes a boolean value- Throws:
IOException
-
value
public JSONWriter value() throws IOException
Writes a null value- Throws:
IOException
-
-