Package net.reyadeyat.nlp.json
Class JsonUtil
java.lang.Object
net.reyadeyat.nlp.json.JsonUtil
- Since:
- 2023.01.01
- Author:
- Mohammad Nabil Mostafa code@reyadeyat.net
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddJsonArrayItemNull(StringBuilder string) static voidaddJsonArrayItemNumber(StringBuilder string, String content) static voidaddJsonArrayItemString(StringBuilder string, String content) static voidaddJsonCloseArray(StringBuilder string) static voidaddJsonCloseObject(StringBuilder string) static voidaddJsonColon(StringBuilder string) static voidaddJsonComma(StringBuilder string) static voidaddJsonOpenArray(StringBuilder string) static voidaddJsonOpenObject(StringBuilder string) static voidaddJsonPropertyNull(StringBuilder string, String tag) static voidaddJsonPropertyNumber(StringBuilder string, String tag, String content) static voidaddJsonPropertyString(StringBuilder string, String tag, String content) static voidaddJsonTag(StringBuilder string, String tag) static voiddeleteFile(String file_path) static <T extends Serializable>
com.google.gson.JsonElementdeserilize(byte[] json_serialized, Class<T> class_type) static com.google.gson.JsonArraygetJsonArray(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static com.google.gson.JsonArraygetJsonArray(String path, com.google.gson.JsonElement json_element) static BooleangetJsonBoolean(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static BooleangetJsonBoolean(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static DoublegetJsonDouble(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static DoublegetJsonDouble(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static com.google.gson.JsonElementgetJsonElement(String path, com.google.gson.JsonElement json_element) static IntegergetJsonInteger(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static IntegergetJsonInteger(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static LonggetJsonLong(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static LonggetJsonLong(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static com.google.gson.JsonObjectgetJsonObject(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static com.google.gson.JsonObjectgetJsonObject(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static com.google.gson.JsonObjectgetJsonObject(String path, com.google.gson.JsonElement json_element) static com.google.gson.JsonPrimitivegetJsonPrimitive(String path, com.google.gson.JsonElement json_element) Json Pathstatic StringgetJsonString(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) static StringgetJsonString(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) static com.google.gson.Gsongson()static com.google.gson.Gsonstatic Object[]javaArray(com.google.gson.JsonArray jsonArray) static Boolean[]javaBooleanArray(com.google.gson.JsonArray jsonArray) static Integer[]javaIntegerArray(com.google.gson.JsonArray jsonArray) static Long[]javaLongArray(com.google.gson.JsonArray jsonArray) static String[]javaStringArray(com.google.gson.JsonArray jsonArray) javaStringArrayList(com.google.gson.JsonArray jsonArray) static com.google.gson.JsonArrayjsonBooleanArray(Boolean[] javaArray) static StringjsonElementToButifulString(com.google.gson.JsonElement json_element) static <CustomeType>
CustomeTypejsonElementToObject(com.google.gson.JsonElement json_element, Class<CustomeType> class_type) static StringjsonElementToString(com.google.gson.JsonElement json_element) static com.google.gson.JsonArrayjsonIntegerArray(Integer[] javaArray) static com.google.gson.JsonArrayjsonLongArray(Long[] javaArray) static com.google.gson.JsonArrayjsonObjectArray(Object[] javaArray) static com.google.gson.JsonArrayjsonStringArray(String[] javaArray) static com.google.gson.JsonElementjsonStringToJsonElelement(String json_stringized) static <CustomeType>
CustomeTypejsonStringToObject(String json_stringized, Class<CustomeType> class_type) static <T extends Serializable>
Tstatic com.google.gson.JsonElementobjectToJsonElement(Object java_object, Class<?> class_type) static <CustomeType>
StringobjectToJsonString(Object java_object, Class<CustomeType> class_type) static com.google.gson.JsonElementstatic com.google.gson.JsonElementreadStream(InputStream input_stream) static voidreclaimGson(com.google.gson.Gson gson) static voidreclaimGsonPretty(com.google.gson.Gson gson) static <T extends Serializable>
byte[]static voidstatic voidwriteStream(OutputStream output_stream, com.google.gson.JsonElement json_element) Json Streams
-
Constructor Details
-
JsonUtil
public JsonUtil()
-
-
Method Details
-
gson
public static com.google.gson.Gson gson() -
gsonPretty
public static com.google.gson.Gson gsonPretty() -
reclaimGson
public static void reclaimGson(com.google.gson.Gson gson) -
reclaimGsonPretty
public static void reclaimGsonPretty(com.google.gson.Gson gson) -
serilize
public static <T extends Serializable> byte[] serilize(com.google.gson.JsonElement json_element, Class<T> class_type) throws Exception - Throws:
Exception
-
objectize
public static <T extends Serializable> T objectize(byte[] json_serialized, Class<T> class_type) throws Exception - Throws:
Exception
-
deserilize
public static <T extends Serializable> com.google.gson.JsonElement deserilize(byte[] json_serialized, Class<T> class_type) throws Exception - Throws:
Exception
-
jsonElementToString
- Throws:
Exception
-
jsonElementToButifulString
public static String jsonElementToButifulString(com.google.gson.JsonElement json_element) throws Exception - Throws:
Exception
-
jsonStringToJsonElelement
public static com.google.gson.JsonElement jsonStringToJsonElelement(String json_stringized) throws Exception - Throws:
Exception
-
objectToJsonString
public static <CustomeType> String objectToJsonString(Object java_object, Class<CustomeType> class_type) throws Exception - Throws:
Exception
-
jsonElementToObject
public static <CustomeType> CustomeType jsonElementToObject(com.google.gson.JsonElement json_element, Class<CustomeType> class_type) throws Exception - Throws:
Exception
-
jsonStringToObject
public static <CustomeType> CustomeType jsonStringToObject(String json_stringized, Class<CustomeType> class_type) throws Exception - Throws:
Exception
-
objectToJsonElement
public static com.google.gson.JsonElement objectToJsonElement(Object java_object, Class<?> class_type) throws Exception - Throws:
Exception
-
getJsonObject
public static com.google.gson.JsonObject getJsonObject(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonArray
public static com.google.gson.JsonArray getJsonArray(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonString
public static String getJsonString(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonBoolean
public static Boolean getJsonBoolean(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonInteger
public static Integer getJsonInteger(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonLong
public static Long getJsonLong(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonDouble
public static Double getJsonDouble(com.google.gson.JsonObject jsonObject, String jsonProperty, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonObject
public static com.google.gson.JsonObject getJsonObject(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonString
public static String getJsonString(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonBoolean
public static Boolean getJsonBoolean(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonInteger
public static Integer getJsonInteger(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonLong
public static Long getJsonLong(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
getJsonDouble
public static Double getJsonDouble(com.google.gson.JsonArray jsonArray, Integer jsonIndex, Boolean nullable) throws Exception - Throws:
Exception
-
addJsonOpenObject
- Throws:
Exception
-
addJsonCloseObject
- Throws:
Exception
-
addJsonOpenArray
- Throws:
Exception
-
addJsonCloseArray
- Throws:
Exception
-
addJsonComma
- Throws:
Exception
-
addJsonColon
- Throws:
Exception
-
addJsonTag
- Throws:
Exception
-
addJsonArrayItemNull
- Throws:
Exception
-
addJsonArrayItemString
- Throws:
Exception
-
addJsonArrayItemNumber
- Throws:
Exception
-
addJsonPropertyNull
- Throws:
Exception
-
addJsonPropertyString
public static void addJsonPropertyString(StringBuilder string, String tag, String content) throws Exception - Throws:
Exception
-
addJsonPropertyNumber
public static void addJsonPropertyNumber(StringBuilder string, String tag, String content) throws Exception - Throws:
Exception
-
javaArray
- Throws:
Exception
-
javaStringArrayList
public static ArrayList<String> javaStringArrayList(com.google.gson.JsonArray jsonArray) throws Exception - Throws:
Exception
-
javaStringArray
- Throws:
Exception
-
javaIntegerArray
- Throws:
Exception
-
javaLongArray
- Throws:
Exception
-
javaBooleanArray
- Throws:
Exception
-
jsonStringArray
- Throws:
Exception
-
jsonIntegerArray
- Throws:
Exception
-
jsonLongArray
- Throws:
Exception
-
jsonBooleanArray
- Throws:
Exception
-
jsonObjectArray
- Throws:
Exception
-
writeStream
public static void writeStream(OutputStream output_stream, com.google.gson.JsonElement json_element) throws Exception Json Streams- Throws:
Exception
-
writeFile
public static void writeFile(String file_path, Boolean overwrite, com.google.gson.JsonElement json_element) throws Exception - Throws:
Exception
-
readStream
- Throws:
Exception
-
readFile
public static com.google.gson.JsonElement readFile(String file_path, Boolean create_if_not_exists) throws Exception - Throws:
Exception
-
deleteFile
- Throws:
Exception
-
getJsonPrimitive
public static com.google.gson.JsonPrimitive getJsonPrimitive(String path, com.google.gson.JsonElement json_element) throws Exception Json Path- Throws:
Exception
-
getJsonObject
public static com.google.gson.JsonObject getJsonObject(String path, com.google.gson.JsonElement json_element) throws Exception - Throws:
Exception
-
getJsonArray
public static com.google.gson.JsonArray getJsonArray(String path, com.google.gson.JsonElement json_element) throws Exception - Throws:
Exception
-
getJsonElement
public static com.google.gson.JsonElement getJsonElement(String path, com.google.gson.JsonElement json_element) throws Exception - Throws:
Exception
-