Constructor and Description |
---|
JSONBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Method called to close builder, so that no more content
can be written.
|
String |
getContent()
Methid called to get the final content after closing the builder
|
void |
writeArrayFieldStart(String fieldName)
Convenience method for outputting a field entry ("member")
(that will contain a JSON Array value), and the START_ARRAY marker.
|
void |
writeBinary(byte[] data,
int offset,
int len)
Method that will output given chunk of binary data as base64
encoded, as a complete String value (surrounded by double quotes).
|
void |
writeBinaryField(String fieldName,
byte[] data)
Convenience method for outputting a field entry ("member")
that contains specified data in base64-encoded form.
|
void |
writeBoolean(boolean state)
Method for outputting literal boolean value (one of
Strings 'true' and 'false').
|
void |
writeBooleanField(String fieldName,
boolean value)
Convenience method for outputting a field entry ("member")
that has a boolean value.
|
void |
writeEndArray()
Method for writing closing marker of a Array.
|
void |
writeEndObject()
Method for writing closing marker of a Object value.
|
void |
writeField(String fieldName,
Object value,
String fieldType)
Convenience method for outputting a field entry ("member")
that has a String value.
|
void |
writeFieldName(String name)
Method for writing a field name.
|
void |
writeNumber(double number)
Method for outputting indicate JSON numeric value.
|
void |
writeNumber(int number)
Method for outputting given value as number.
|
void |
writeNumberField(String fieldName,
double value)
Convenience method for outputting a field entry ("member")
that has the specified numeric value.
|
void |
writeNumberField(String fieldName,
int value)
Convenience method for outputting a field entry ("member")
that has the specified numeric value.
|
void |
writeObjectFieldStart(String fieldName)
Convenience method for outputting a field entry ("member")
(that will contain a JSON Object value), and the START_OBJECT marker.
|
void |
writePrimitive(Object value,
String fieldType)
Convenience method for outputting a primitive
that has a primitive value.
|
void |
writeStartArray()
Method for writing start marker of a Array value.
|
void |
writeStartObject()
Method for writing starting marker of a Object value.
|
void |
writeString(String text)
Method for outputting a String value.
|
void |
writeStringField(String fieldName,
String value)
Convenience method for outputting a field entry ("member")
that has a String value.
|
public JSONBuilder() throws IOException
IOException
public void writeStartArray() throws IOException
Builder
writeStartArray
in interface Builder
IOException
public void writeEndArray() throws IOException
Builder
writeEndArray
in interface Builder
IOException
public void writeStartObject() throws IOException
Builder
writeStartObject
in interface Builder
IOException
public void writeEndObject() throws IOException
Builder
writeEndObject
in interface Builder
IOException
public void writeFieldName(String name) throws IOException
Builder
writeFieldName
in interface Builder
IOException
public void writeString(String text) throws IOException
Builder
writeString
in interface Builder
IOException
public void writeBinary(byte[] data, int offset, int len) throws IOException
Builder
writeBinary
in interface Builder
IOException
public void writeNumber(int number) throws IOException
Builder
writeNumber
in interface Builder
number
- Number value to writeIOException
public void writeNumber(double number) throws IOException
Builder
writeNumber
in interface Builder
number
- Number value to writeIOException
public void writeBoolean(boolean state) throws IOException
Builder
writeBoolean
in interface Builder
IOException
public void writeStringField(String fieldName, String value) throws IOException
Builder
writeFieldName(fieldName); writeString(value);
writeStringField
in interface Builder
IOException
public void writeField(String fieldName, Object value, String fieldType) throws IOException
Builder
writeFieldName(fieldName); writeString(value);
writeField
in interface Builder
IOException
public void writeBooleanField(String fieldName, boolean value) throws IOException
Builder
writeFieldName(fieldName); writeBoolean(value);
writeBooleanField
in interface Builder
IOException
public void writeNumberField(String fieldName, int value) throws IOException
Builder
writeFieldName(fieldName); writeNumber(value);
writeNumberField
in interface Builder
IOException
public void writeNumberField(String fieldName, double value) throws IOException
Builder
writeFieldName(fieldName); writeNumber(value);
writeNumberField
in interface Builder
IOException
public void writeBinaryField(String fieldName, byte[] data) throws IOException
Builder
writeFieldName(fieldName); writeBinary(value);
writeBinaryField
in interface Builder
IOException
public void writeArrayFieldStart(String fieldName) throws IOException
Builder
writeFieldName(fieldName); writeStartArray();Note: caller still has to take care to close the array (by calling {#link #writeEndArray}) after writing all values of the value Array.
writeArrayFieldStart
in interface Builder
IOException
public void writeObjectFieldStart(String fieldName) throws IOException
Builder
writeFieldName(fieldName); writeStartObject();Note: caller still has to take care to close the Object (by calling {#link #writeEndObject}) after writing all entries of the value Object.
writeObjectFieldStart
in interface Builder
IOException
public void close() throws IOException
Builder
close
in interface Builder
IOException
public void writePrimitive(Object value, String fieldType) throws IOException
Builder
writePrimitive
in interface Builder
IOException
public String getContent() throws IOException
Builder
getContent
in interface Builder
IOException
Copyright © 2019 WSO2. All rights reserved.