public class JsonUtil extends Object
| Constructor and Description |
|---|
JsonUtil() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.jena.atlas.json.JsonValue |
asJson(Object obj)
Convert java objects to JSON objects.
|
static org.apache.jena.atlas.json.JsonObject |
emptyObject()
Return a new singleton empty object
|
static Object |
fromJson(org.apache.jena.atlas.json.JsonValue jv)
Convert a JSON value to a corresponding plain Java value.
|
static boolean |
getBooleanValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
boolean dflt) |
static int |
getIntValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
int dflt) |
static long |
getLongValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
long dflt) |
static <T> T |
getPath(org.apache.jena.atlas.json.JsonValue root,
Class<T> target,
Object... selectors)
Return an element of a JSON structure by following a sequence of object field
selectors (strings) or array indexes (integers) and return the java-ized
version of the leaf.
|
static Object |
getPath(org.apache.jena.atlas.json.JsonValue root,
Object... selectors)
Return an element of a JSON structure by following a sequence of object field
selectors (strings) or array indexes (integers) and return the java-ized
version of the leaf.
|
static String |
getStringValue(org.apache.jena.atlas.json.JsonObject jo,
String field) |
static String |
getStringValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
String dflt) |
static org.apache.jena.atlas.json.JsonValue |
loadFromFile(String filename) |
static org.apache.jena.atlas.json.JsonObject |
makeJson(org.apache.jena.atlas.json.JsonObject base,
Object... args)
Create a JSON object as a copy of an existing object, with new/replacement key values
taken from the args
|
static org.apache.jena.atlas.json.JsonObject |
makeJson(Object... args)
Create a simple Json Object.
|
static org.apache.jena.atlas.json.JsonObject |
merge(org.apache.jena.atlas.json.JsonObject base,
org.apache.jena.atlas.json.JsonObject extend)
Create a new json object by cloning one object and then asserting all values from the second.
|
static org.apache.jena.atlas.json.JsonObject |
mergeInto(org.apache.jena.atlas.json.JsonObject base,
org.apache.jena.atlas.json.JsonObject extend)
Merge all the extend values into the base object returning the base object, no copy.
|
static org.apache.jena.atlas.json.JsonArray |
readArray(String filename)
Parse a JSON or YAML file to an array of json objects, supports multi-document yaml files
|
static org.apache.jena.atlas.json.JsonArray |
readArray(String filename,
InputStream is)
Parse a JSON or YAML file to an array of json objects, supports multi-document yaml files
|
static org.apache.jena.atlas.json.JsonObject |
readObject(String filename)
Parse a JSON or YAML file to a json object.
|
static org.apache.jena.atlas.json.JsonObject |
readObject(String filename,
InputStream is)
Parse a JSON or YAML file to a json object.
|
public static org.apache.jena.atlas.json.JsonValue loadFromFile(String filename)
public static String getStringValue(org.apache.jena.atlas.json.JsonObject jo, String field)
public static String getStringValue(org.apache.jena.atlas.json.JsonObject jo, String field, String dflt)
public static int getIntValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
int dflt)
public static long getLongValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
long dflt)
public static boolean getBooleanValue(org.apache.jena.atlas.json.JsonObject jo,
String field,
boolean dflt)
public static org.apache.jena.atlas.json.JsonValue asJson(Object obj)
public static org.apache.jena.atlas.json.JsonObject makeJson(Object... args)
args - alternating parameter names and parameter valuespublic static org.apache.jena.atlas.json.JsonObject makeJson(org.apache.jena.atlas.json.JsonObject base,
Object... args)
base - object to copy, can be nullargs - alternating parameter names and parameter valuespublic static Object fromJson(org.apache.jena.atlas.json.JsonValue jv)
public static Object getPath(org.apache.jena.atlas.json.JsonValue root, Object... selectors)
public static <T> T getPath(org.apache.jena.atlas.json.JsonValue root,
Class<T> target,
Object... selectors)
public static org.apache.jena.atlas.json.JsonObject emptyObject()
public static org.apache.jena.atlas.json.JsonObject merge(org.apache.jena.atlas.json.JsonObject base,
org.apache.jena.atlas.json.JsonObject extend)
public static org.apache.jena.atlas.json.JsonObject mergeInto(org.apache.jena.atlas.json.JsonObject base,
org.apache.jena.atlas.json.JsonObject extend)
public static org.apache.jena.atlas.json.JsonArray readArray(String filename, InputStream is)
public static org.apache.jena.atlas.json.JsonArray readArray(String filename) throws FileNotFoundException
FileNotFoundExceptionpublic static org.apache.jena.atlas.json.JsonObject readObject(String filename, InputStream is)
public static org.apache.jena.atlas.json.JsonObject readObject(String filename) throws FileNotFoundException
FileNotFoundExceptionCopyright © 2017. All rights reserved.