public final class Json extends Object
 To parse a given JSON input, use the parse() methods like in this
 example:
 
JsonObject object = Json.parse(string).asObject();
 To create a JSON data structure to be serialized, use the methods
 value(), array(), and object(). For example, the following
 snippet will produce the JSON string {"foo": 23, "bar": true}:
 
 String string = Json.object().add("foo", 23).add("bar", true).toString();
 
 
 To create a JSON array from a given Java array, you can use one of the array()
 methods with varargs parameters:
 
String[] names = ... JsonArray array = Json.array(names);
| Modifier and Type | Field and Description | 
|---|---|
static JsonValue | 
FALSE
Represents the JSON literal  
false. | 
static JsonValue | 
NULL
Represents the JSON literal  
null. | 
static JsonValue | 
TRUE
Represents the JSON literal  
true. | 
| Modifier and Type | Method and Description | 
|---|---|
static JsonArray | 
array()
Creates a new empty JsonArray. 
 | 
static JsonArray | 
array(boolean... values)
Creates a new JsonArray that contains the JSON representations of the given
  
boolean values. | 
static JsonArray | 
array(double... values)
Creates a new JsonArray that contains the JSON representations of the given  
double
 values. | 
static JsonArray | 
array(float... values)
Creates a new JsonArray that contains the JSON representations of the given  
float
 values. | 
static JsonArray | 
array(int... values)
Creates a new JsonArray that contains the JSON representations of the given  
int
 values. | 
static JsonArray | 
array(long... values)
Creates a new JsonArray that contains the JSON representations of the given  
long
 values. | 
static JsonArray | 
array(String... strings)
Creates a new JsonArray that contains the JSON representations of the given strings. 
 | 
static JsonObject | 
object()
Creates a new empty JsonObject. 
 | 
static JsonValue | 
parse(Reader reader)
Reads the entire input from the given reader and parses it as JSON. 
 | 
static JsonValue | 
parse(String string)
Parses the given input string as JSON. 
 | 
static JsonValue | 
value(boolean value)
Returns a JsonValue instance that represents the given  
boolean value. | 
static JsonValue | 
value(double value)
Returns a JsonValue instance that represents the given  
double value. | 
static JsonValue | 
value(float value)
Returns a JsonValue instance that represents the given  
float value. | 
static JsonValue | 
value(int value)
Returns a JsonValue instance that represents the given  
int value. | 
static JsonValue | 
value(long value)
Returns a JsonValue instance that represents the given  
long value. | 
static JsonValue | 
value(String string)
Returns a JsonValue instance that represents the given string. 
 | 
public static final JsonValue NULL
null.public static final JsonValue TRUE
true.public static final JsonValue FALSE
false.public static JsonValue value(int value)
int value.value - the value to get a JSON representation forpublic static JsonValue value(long value)
long value.value - the value to get a JSON representation forpublic static JsonValue value(float value)
float value.value - the value to get a JSON representation forpublic static JsonValue value(double value)
double value.value - the value to get a JSON representation forpublic static JsonValue value(String string)
string - the string to get a JSON representation forpublic static JsonValue value(boolean value)
boolean value.value - the value to get a JSON representation forpublic static JsonArray array()
public static JsonArray array(int... values)
int
 values.values - the values to be included in the new JSON arraypublic static JsonArray array(long... values)
long
 values.values - the values to be included in the new JSON arraypublic static JsonArray array(float... values)
float
 values.values - the values to be included in the new JSON arraypublic static JsonArray array(double... values)
double
 values.values - the values to be included in the new JSON arraypublic static JsonArray array(boolean... values)
boolean values.values - the values to be included in the new JSON arraypublic static JsonArray array(String... strings)
strings - the strings to be included in the new JSON arraypublic static JsonObject object()
public static JsonValue parse(String string)
string - the input string, must be valid JSONParseException - if the input is not valid JSONpublic static JsonValue parse(Reader reader) throws IOException
 Characters are read in chunks into an input buffer. Hence, wrapping a reader in an additional
 BufferedReader likely won't improve reading performance.
 
reader - the reader to read the JSON value fromIOException - if an I/O error occurs in the readerParseException - if the input is not valid JSONCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.