Class JsonUtils

java.lang.Object
com.idmedia.translationstudio.impl.util.JsonUtils

public class JsonUtils extends Object
Json Utility class
Author:
Phillip Austerfield invalid input: '<'phillip.austerfield@idmedia.com>
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable org.json.simple.JSONArray
    getJsonArray(@NotNull org.json.simple.JSONObject pJson, @NotNull String sField)
    Get the JSON Array Object
    static boolean
    getJsonBoolean(@NotNull org.json.simple.JSONObject pObject, @NotNull String sProperty, boolean bDefault)
    Get a boolean propery
    static long
    getJsonNumber(@NotNull org.json.simple.JSONObject pJson, @NotNull String sField, long lDefault)
    Get a number property
    static @Nullable org.json.simple.JSONObject
    getJsonObject(org.json.simple.JSONObject pObject, String sProperty)
     
    static @NotNull String
    getJsonString(@NotNull org.json.simple.JSONObject pObject, @NotNull String sProperty)
    Get the JSON String
    static @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.JSONArray
    parseJsonArray(@NotNull File pFile)
    Read the given JSON file
    static @Nullable org.json.simple.JSONObject
    parseJsonObject(@NotNull File pFile)
    Read the given JSON file
    static @NotNull org.json.simple.JSONObject
    parseJsonObject(@NotNull String sJson)
    Read the given JSON String
    static @NotNull List<String>
    stringArrayToList(@NotNull org.json.simple.JSONObject pObject, @NotNull String sField, boolean bRemoveEmptyStrings)
     
    static @NotNull org.json.simple.JSONArray
    toArray(@NotNull List<String> vsList)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - JSON
      sField - 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 - Json
      sField - Property
      lDefault - Default, if the field does not exist
      Returns:
      Value or default
    • toArray

      @NotNull public static @NotNull org.json.simple.JSONArray toArray(@NotNull @NotNull List<String> vsList)
    • stringArrayToList

      @NotNull public static @NotNull List<String> stringArrayToList(@NotNull @NotNull org.json.simple.JSONObject pObject, @NotNull @NotNull String sField, boolean bRemoveEmptyStrings)
    • jsonArrayToArrayList

      @NotNull public static @NotNull List<org.json.simple.JSONObject> jsonArrayToArrayList(@NotNull @NotNull org.json.simple.JSONObject pObject, @NotNull @NotNull String sField, boolean bRemoveEmptyObjects)
    • jsonArrayToList

      @NotNull public static @NotNull List<org.json.simple.JSONObject> jsonArrayToList(@NotNull @NotNull org.json.simple.JSONObject pObject, @NotNull @NotNull String sField, boolean bRemoveEmptyObjects)