Package com.codedjson
Class Json
- java.lang.Object
-
- com.codedjson.utils.Base
-
- com.codedjson.utils.Is
-
- com.codedjson.Json
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
json
List<String>
jsonKeys
List<Object>
jsonValues
-
Fields inherited from class com.codedjson.utils.Base
baseFileObj, commaSeparatedLines, commentedLines, content, filePath, gson, isContextConverted, isFilePath, isInjectDone, isInjectExist
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getAllKeys()
Iteratively parses all keys and returns it in List< String>List<Object>
getAllValues()
Iteratively parses all values and returns it in List< String>.
Requires getAllKeys() before.protected Object
getValueFromKey(String key)
boolean
isContentJson()
Checks if the deserialized object is of json typestatic boolean
isContentJson(String content)
Checks if the passed content is of json type.static boolean
isContentJson(Path path)
Checks if the file content is of json type.Object
parse()
Parse value with no keys.Object
parse(String key)
Parse value with JPath as key.protected ParsedValue
parseValue(String key)
-
Methods inherited from class com.codedjson.utils.Is
isImport, isRelativeJPath, isSingleLineComent
-
Methods inherited from class com.codedjson.utils.Base
appendPath, getDirectory, getFullPath, getType, isAbsolutePath, parseJson, read
-
-
-
-
Constructor Detail
-
Json
public Json(String filePath, boolean isFilePath) throws FileNotFoundException
- Throws:
FileNotFoundException
-
Json
public Json(String content)
-
-
Method Detail
-
isContentJson
public boolean isContentJson()
Checks if the deserialized object is of json type- Returns:
- boolean
-
isContentJson
public static boolean isContentJson(String content)
Checks if the passed content is of json type.- Parameters:
content
- Test content in string- Returns:
- boolean
-
isContentJson
public static boolean isContentJson(Path path)
Checks if the file content is of json type.- Parameters:
path
- File path- Returns:
- boolean
-
getAllKeys
public List<String> getAllKeys()
Iteratively parses all keys and returns it in List< String>- Returns:
- List< String> of all the keys
-
getAllValues
public List<Object> getAllValues() throws NullJsonKeys
Iteratively parses all values and returns it in List< String>.
Requires getAllKeys() before.- Returns:
- List< String> of all the keys
- Throws:
NullJsonKeys
- IfgetAllKeys()
is not called before
-
parseValue
protected ParsedValue parseValue(String key)
-
parse
public Object parse()
Parse value with no keys. Returns the root json object- Returns:
-
parse
public Object parse(String key) throws InvalidJPathError
Parse value with JPath as key.- Parameters:
key
- JPath- Returns:
- Throws:
IllegalValueType
InvalidJPathError
-
-