public class JsonUtils
extends java.lang.Object
Provides some useful JSON-related functions.
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addSRIDToGeoJSON(org.codehaus.jackson.map.ObjectMapper om, org.codehaus.jackson.JsonNode json, int srid) |
static java.lang.String |
addSRIDToGeoJSON(java.lang.String json, int srid)
Returns a GeoJSON string made from the given json string and the given SRID
|
static java.lang.String |
createHierarchyCountRecord(java.lang.String id, long result)
Generates a count result in JSON format.
|
static int |
getDimensions(org.codehaus.jackson.JsonNode geomElem) |
static int |
getDimensions(java.lang.String json)
Returns the dimensions of a geoJSON object in the form: {"type":<geometry-type", "coordinates":[c1,c2,....cn]}
|
static org.codehaus.jackson.JsonNode |
getNode(org.codehaus.jackson.JsonNode rootNode, java.lang.String[] nodePath)
Searches a JSON node given a root node and the path of the searched node.
|
static org.codehaus.jackson.JsonNode |
getNode(org.codehaus.jackson.JsonNode rootNode, java.lang.String[][] nodePaths)
Searches a JSON node given a root node and group of paths where the searched node could be.
|
static java.lang.String |
getTextValue(org.codehaus.jackson.JsonNode node)
Gets a text value of a JSON node containing either, text or numbers
|
static <V> V |
loadJsonAsObject(org.apache.hadoop.fs.Path jsonPath, java.lang.Class<? extends V> jsonClass, org.apache.hadoop.conf.Configuration conf) |
static oracle.spatial.geometry.JGeometry |
readGeomCollection(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a geometry collection from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readGeometry(org.codehaus.jackson.JsonNode geomElem, int srid) |
static oracle.spatial.geometry.JGeometry |
readGeometry(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a JGeometry from a geoJSON node in the form: {"type":<geometry-type", "coordinates":[c1,c2,....cn]}
|
static oracle.spatial.geometry.JGeometry |
readGeometry(java.lang.String json)
Reads a JGeometry from a geoJSON string in the form: {"type":<geometry-type", "crs": { "type": "name", "properties": {"name": "EPSG:SRID"}}"coordinates":[c1,c2,....cn]}
|
static oracle.spatial.geometry.JGeometry |
readGeometry(java.lang.String json, int srid)
Reads a JGeometry from a geoJSON string in the form: {"type":<geometry-type", "coordinates":[c1,c2,....cn]}
|
static oracle.spatial.geometry.JGeometry |
readGeometry(java.lang.String json, int dimensions, int srid)
Reads a JGeometry from a geoJSON string in the form: {"type":<geometry-type", "coordinates":[c1,c2,....cn]}
|
static oracle.spatial.geometry.JGeometry |
readLine(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a line geometry collection from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readMultiLineString(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a MultiLineString from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readMultiPoint(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a MultiPoint element from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readMultiPolygon(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a multi-polygon geometry collection from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readPoint(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a point geometry collection from a geoJSON node
|
static oracle.spatial.geometry.JGeometry |
readPolygon(org.codehaus.jackson.JsonNode geomElem, int dimensions, int srid)
Reads a polygon geometry collection from a geoJSON node
|
public static java.lang.String createHierarchyCountRecord(java.lang.String id,
long result)
id - an idresult - the count result
public static oracle.spatial.geometry.JGeometry readGeometry(java.lang.String json,
int dimensions,
int srid)
json - a geometry in JSON format. The string must only contain geoJSON content.dimensions - the geometry dimensionssrid - the resulting geometry SRIDpublic static oracle.spatial.geometry.JGeometry readGeometry(java.lang.String json)
json - a geometry in JSON format. The string must only contain geoJSON content.
public static oracle.spatial.geometry.JGeometry readGeometry(java.lang.String json,
int srid)
json - a geometry in JSON format. The string must only contain geoJSON content.srid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readGeometry(org.codehaus.jackson.JsonNode geomElem,
int srid)
public static oracle.spatial.geometry.JGeometry readGeometry(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static java.lang.String addSRIDToGeoJSON(java.lang.String json,
int srid)
json - a geometry in JSON format. The string must only contain geoJSON content.srid - SRID
public static void addSRIDToGeoJSON(org.codehaus.jackson.map.ObjectMapper om,
org.codehaus.jackson.JsonNode json,
int srid)
public static oracle.spatial.geometry.JGeometry readGeomCollection(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readMultiPolygon(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readPolygon(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readMultiLineString(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readPoint(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readLine(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static oracle.spatial.geometry.JGeometry readMultiPoint(org.codehaus.jackson.JsonNode geomElem,
int dimensions,
int srid)
geomElem - a JSON node with the geometry contentdimensions - the geometry dimensionssrid - the resulting geometry SRID
public static org.codehaus.jackson.JsonNode getNode(org.codehaus.jackson.JsonNode rootNode,
java.lang.String[][] nodePaths)
rootNode - the JSON node from where the search startsnodePaths - a two dimensional array. First dimension elements are JSON paths, there can be one or more paths. Elements of each path are names of JSON nodes.
public static org.codehaus.jackson.JsonNode getNode(org.codehaus.jackson.JsonNode rootNode,
java.lang.String[] nodePath)
rootNode - the JSON node from where the search startsnodePath - the path to the searched node. Each array entry is the name of a JSON node.public static java.lang.String getTextValue(org.codehaus.jackson.JsonNode node)
node - a JSON nodepublic static int getDimensions(org.codehaus.jackson.JsonNode geomElem)
public static int getDimensions(java.lang.String json)
json - a geometry in JSON format. The string must only contain geoJSON content.
public static <V> V loadJsonAsObject(org.apache.hadoop.fs.Path jsonPath,
java.lang.Class<? extends V> jsonClass,
org.apache.hadoop.conf.Configuration conf)
throws java.io.IOException
java.io.IOException