Package org.panda_lang.pandomium.util
Class JsonUtils
java.lang.Object
org.panda_lang.pandomium.util.JsonUtils
public class JsonUtils extends Object
- Author:
- Osiris-Team
-
Constructor Summary
Constructors Constructor Description JsonUtils() -
Method Summary
Modifier and Type Method Description com.google.gson.JsonArraygetJsonArray(String url)List<com.google.gson.JsonObject>getJsonArrayAsList(String url)Turns a JsonArray with its objects into a list.com.google.gson.JsonElementgetJsonElement(String input_url)Returns the json-element.com.google.gson.JsonObjectgetJsonObject(String url)Gets a single JsonObject.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
getJsonElement
public com.google.gson.JsonElement getJsonElement(String input_url) throws IOException, HttpErrorExceptionReturns the json-element. This can be a json-array or a json-object.- Parameters:
input_url- The url which leads to the json file.- Returns:
- JsonElement
- Throws:
Exception- When status code other than 200.IOExceptionHttpErrorException
-
getJsonArray
public com.google.gson.JsonArray getJsonArray(String url) throws IOException, HttpErrorException, WrongJsonTypeException -
getJsonArrayAsList
public List<com.google.gson.JsonObject> getJsonArrayAsList(String url) throws IOException, HttpErrorException, WrongJsonTypeExceptionTurns a JsonArray with its objects into a list.- Parameters:
url- The url where to find the json file.- Returns:
- A list with JsonObjects or null if there was a error with the url.
- Throws:
IOExceptionHttpErrorExceptionWrongJsonTypeException
-
getJsonObject
public com.google.gson.JsonObject getJsonObject(String url) throws IOException, HttpErrorException, WrongJsonTypeExceptionGets a single JsonObject.- Parameters:
url- The url where to find the json file.- Returns:
- A JsonObject or null if there was a error with the url.
- Throws:
IOExceptionHttpErrorExceptionWrongJsonTypeException
-