Package com.crowdar.core
Class JsonUtils
- java.lang.Object
-
- com.crowdar.core.JsonUtils
-
public class JsonUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description JsonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tdeserialize(java.lang.String json, java.lang.Class<T> type)static java.lang.StringgetJSON(java.nio.file.Path file)Given a Json file location, this method returns that JSON as a Stringstatic java.lang.StringgetJSONFromFile(java.lang.String fileName)Given a Json file location, this method returns that JSON as a Stringstatic <T> TgetJSONFromFileAsObject(java.lang.String file, java.lang.Class<T> valueType)static java.lang.StringgetJSONFromPath(java.lang.String path)static <T> java.util.List<T>getListJSONFromFileAsObject(java.lang.String file, java.lang.Class<T> valueType)static booleanisJSONValid(java.lang.Object jsonObject)static booleanisJSONValid(java.lang.String json)static java.lang.StringprettyJsonToCompact(java.lang.String prettyJson)static java.lang.StringreplaceVarsFromPropertyManager(java.lang.String jsonUnparsed)static java.lang.Stringserialize(java.lang.Object json)
-
-
-
Method Detail
-
deserialize
public static <T> T deserialize(java.lang.String json, java.lang.Class<T> type)
-
serialize
public static java.lang.String serialize(java.lang.Object json)
-
isJSONValid
public static boolean isJSONValid(java.lang.Object jsonObject)
-
isJSONValid
public static boolean isJSONValid(java.lang.String json)
-
getJSONFromFile
public static java.lang.String getJSONFromFile(java.lang.String fileName) throws java.io.IOExceptionGiven a Json file location, this method returns that JSON as a String- Parameters:
fileName-- Returns:
- String (json)
- Throws:
java.io.IOException
-
getJSONFromPath
public static java.lang.String getJSONFromPath(java.lang.String path) throws java.io.IOException- Throws:
java.io.IOException
-
getJSONFromFileAsObject
public static <T> T getJSONFromFileAsObject(java.lang.String file, java.lang.Class<T> valueType) throws java.io.IOException- Throws:
java.io.IOException
-
getListJSONFromFileAsObject
public static <T> java.util.List<T> getListJSONFromFileAsObject(java.lang.String file, java.lang.Class<T> valueType) throws java.io.IOException- Throws:
java.io.IOException
-
getJSON
public static java.lang.String getJSON(java.nio.file.Path file) throws java.io.IOExceptionGiven a Json file location, this method returns that JSON as a String- Parameters:
file-- Returns:
- String (json)
- Throws:
java.io.IOException
-
prettyJsonToCompact
public static java.lang.String prettyJsonToCompact(java.lang.String prettyJson)
-
replaceVarsFromPropertyManager
public static java.lang.String replaceVarsFromPropertyManager(java.lang.String jsonUnparsed) throws java.io.IOException- Parameters:
jsonUnparsed- json as String with Handlebars {{ }} to be replaced from propertyManager- Returns:
- String with replaced handlebars vars
- Throws:
java.io.IOException
-
-