Class JsonUtils
java.lang.Object
com.idmedia.translationstudio.impl.util.JsonUtils
Json Utility class
- Author:
- Phillip Austerfield invalid input: '<'phillip.austerfield@idmedia.com>
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable org.json.simple.JSONArraygetJsonArray(@NotNull org.json.simple.JSONObject pJson, @NotNull String sField) Get the JSON Array Objectstatic booleangetJsonBoolean(@NotNull org.json.simple.JSONObject pObject, @NotNull String sProperty, boolean bDefault) Get a boolean properystatic longgetJsonNumber(@NotNull org.json.simple.JSONObject pJson, @NotNull String sField, long lDefault) Get a number propertystatic @Nullable org.json.simple.JSONObjectgetJsonObject(org.json.simple.JSONObject pObject, String sProperty) static @NotNull StringgetJsonString(@NotNull org.json.simple.JSONObject pObject, @NotNull String sProperty) Get the JSON Stringstatic @NotNull List<org.json.simple.JSONObject> jsonArrayToArrayList(@NotNull org.json.simple.JSONObject pObject, @NotNull String sField, boolean bRemoveEmptyObjects) static @NotNull List<org.json.simple.JSONObject> jsonArrayToList(@NotNull org.json.simple.JSONObject pObject, @NotNull String sField, boolean bRemoveEmptyObjects) static @Nullable org.json.simple.JSONArrayparseJsonArray(@NotNull File pFile) Read the given JSON filestatic @Nullable org.json.simple.JSONObjectparseJsonObject(@NotNull File pFile) Read the given JSON filestatic @NotNull org.json.simple.JSONObjectparseJsonObject(@NotNull String sJson) Read the given JSON StringstringArrayToList(@NotNull org.json.simple.JSONObject pObject, @NotNull String sField, boolean bRemoveEmptyStrings) static @NotNull org.json.simple.JSONArray
-
Method Details
-
getJsonString
@NotNull public static @NotNull String getJsonString(@NotNull @NotNull org.json.simple.JSONObject pObject, @NotNull @NotNull String sProperty) Get the JSON String- Parameters:
pObject-sProperty-- Returns:
-
getJsonObject
@Nullable public static @Nullable org.json.simple.JSONObject getJsonObject(org.json.simple.JSONObject pObject, String sProperty) -
getJsonBoolean
public static boolean getJsonBoolean(@NotNull @NotNull org.json.simple.JSONObject pObject, @NotNull @NotNull String sProperty, boolean bDefault) Get a boolean propery- Parameters:
pObject-sProperty-bDefault-- Returns:
-
getJsonArray
@Nullable public static @Nullable org.json.simple.JSONArray getJsonArray(@NotNull @NotNull org.json.simple.JSONObject pJson, @NotNull @NotNull String sField) Get the JSON Array Object- Parameters:
pJson- JSONsField- Array field- Returns:
- Array or null
-
parseJsonObject
@Nullable public static @Nullable org.json.simple.JSONObject parseJsonObject(@NotNull @NotNull File pFile) Read the given JSON file- Parameters:
pFile- Input file- Returns:
- Json object or NULL if not a json object
-
parseJsonArray
@Nullable public static @Nullable org.json.simple.JSONArray parseJsonArray(@NotNull @NotNull File pFile) Read the given JSON file- Parameters:
pFile- Input file- Returns:
- Json object or NULL if not a json object
-
parseJsonObject
@NotNull public static @NotNull org.json.simple.JSONObject parseJsonObject(@NotNull @NotNull String sJson) Read the given JSON String- Parameters:
sJson- JSON- Returns:
- Json object
-
getJsonNumber
public static long getJsonNumber(@NotNull @NotNull org.json.simple.JSONObject pJson, @NotNull @NotNull String sField, long lDefault) Get a number property- Parameters:
pJson- JsonsField- PropertylDefault- Default, if the field does not exist- Returns:
- Value or default
-
toArray
-
stringArrayToList
-
jsonArrayToArrayList
-
jsonArrayToList
-