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(ObjectMapper om, 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(JsonNode geomElem) |
static JsonNode |
getNode(JsonNode rootNode, java.lang.String[] nodePath)
Searches a JSON node given a root node and the path of the searched node.
|
static JsonNode |
getNode(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(JsonNode node)
Gets a text value of a JSON node containing either, text or numbers
|
static <V> V |
loadJsonAsObject(Path jsonPath, java.lang.Class<? extends V> jsonClass, Configuration conf) |
static JGeometry |
readGeomCollection(JsonNode geomElem, int dimensions, int srid)
Reads a geometry collection from a geoJSON node
|
static JGeometry |
readGeometry(JsonNode geomElem, int srid) |
static JGeometry |
readGeometry(JsonNode geomElem, int dimensions, int srid)
Reads a JGeometry from a geoJSON node in the form: {"type":<geometry-type>", "coordinates":[c1,c2,....cn]}
|
static 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 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 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 JGeometry |
readLine(JsonNode geomElem, int dimensions, int srid)
Reads a line geometry collection from a geoJSON node
|
static JGeometry |
readMultiLineString(JsonNode geomElem, int dimensions, int srid)
Reads a MultiLineString from a geoJSON node
|
static JGeometry |
readMultiPoint(JsonNode geomElem, int dimensions, int srid)
Reads a MultiPoint element from a geoJSON node
|
static JGeometry |
readMultiPolygon(JsonNode geomElem, int dimensions, int srid)
Reads a multi-polygon geometry collection from a geoJSON node
|
static JGeometry |
readPoint(JsonNode geomElem, int dimensions, int srid)
Reads a point geometry collection from a geoJSON node
|
static JGeometry |
readPolygon(JsonNode geomElem, int dimensions, int srid)
Reads a polygon geometry collection from a geoJSON node
|
public static void addSRIDToGeoJSON(ObjectMapper om, JsonNode json, int 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
- SRIDpublic static java.lang.String createHierarchyCountRecord(java.lang.String id, long result)
id
- an idresult
- the count resultpublic static int getDimensions(JsonNode geomElem)
public static JsonNode getNode(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 JsonNode getNode(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 java.lang.String getTextValue(JsonNode node)
node
- a JSON nodepublic static <V> V loadJsonAsObject(Path jsonPath, java.lang.Class<? extends V> jsonClass, Configuration conf) throws java.io.IOException
java.io.IOException
public static JGeometry readGeomCollection(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readGeometry(JsonNode geomElem, int srid)
public static JGeometry readGeometry(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readGeometry(java.lang.String json)
json
- a geometry in JSON format. The string must only contain geoJSON content.public static 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 SRIDpublic static 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 JGeometry readLine(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readMultiLineString(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readMultiPoint(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readMultiPolygon(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readPoint(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDpublic static JGeometry readPolygon(JsonNode geomElem, int dimensions, int srid)
geomElem
- a JSON node with the geometry contentdimensions
- the geometry dimensionssrid
- the resulting geometry SRIDCopyright © 2017, 2019 Oracle and/or its affiliates. All Rights Reserved.