Package com.marswars.util
Class JSONReader
java.lang.Object
com.marswars.util.JSONReader
- Direct Known Subclasses:
ConstantsLoader,MWPreferences
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.fasterxml.jackson.databind.ObjectMapperprotected com.fasterxml.jackson.databind.JsonNode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetChildren(com.fasterxml.jackson.databind.JsonNode parent) protected voidprotected voidLoads JSON content from a specific file into a JSON tree for parsingprotected com.fasterxml.jackson.databind.JsonNodesearchArrayForPair(com.fasterxml.jackson.databind.JsonNode starting, String child_key, String child_value) Searches through a JSON array to find a specific key value pairprotected static com.fasterxml.jackson.databind.JsonNodeWalks the JSON tree down to a specific node
-
Field Details
-
root_node_
protected com.fasterxml.jackson.databind.JsonNode root_node_ -
mapper_
protected com.fasterxml.jackson.databind.ObjectMapper mapper_
-
-
Constructor Details
-
JSONReader
public JSONReader()
-
-
Method Details
-
loadJson
- Throws:
IOException
-
loadJson
Loads JSON content from a specific file into a JSON tree for parsing- Parameters:
json_file-- Throws:
IOException
-
searchArrayForPair
protected com.fasterxml.jackson.databind.JsonNode searchArrayForPair(com.fasterxml.jackson.databind.JsonNode starting, String child_key, String child_value) throws JSONReader.ConstantParseError Searches through a JSON array to find a specific key value pair- Parameters:
starting- the starting json node to search fromchild_key- the primary key to look forchild_value- the value of the primary key- Returns:
- the node that contains child_key with the value of child_value
- Throws:
JSONReader.ConstantParseError- when node is not an array or child_key and value cannot be found
-
walkTree
protected static com.fasterxml.jackson.databind.JsonNode walkTree(com.fasterxml.jackson.databind.JsonNode starting, String... path_steps) Walks the JSON tree down to a specific node- Parameters:
path_steps- a list of path steps to take along the way- Returns:
- the resulting node at the end of walking
-
getChildren
-