All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.nichetoolkit.rest.util.JsonUtils Maven / Gradle / Ivy

The newest version!
package io.github.nichetoolkit.rest.util;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.ArrayType;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.MapType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import io.github.nichetoolkit.rest.RestResult;
import io.github.nichetoolkit.rest.error.ClassUnsupportedException;
import io.github.nichetoolkit.rest.error.json.JsonParseBeanException;
import io.github.nichetoolkit.rest.error.json.JsonParseListException;
import io.github.nichetoolkit.rest.error.json.JsonParseMapException;
import io.github.nichetoolkit.rest.error.json.JsonParseSetException;
import io.github.nichetoolkit.rest.error.supply.JsonParseException;
import io.github.nichetoolkit.rest.helper.JsonHelper;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * JsonUtils
 * 

The json utils class.

* @author Cyan ([email protected]) * @see lombok.extern.slf4j.Slf4j * @see java.lang.SuppressWarnings * @since Jdk1.8 */ @Slf4j @SuppressWarnings({"TypeParameterUnusedInFormals","SameNameButDifferent"}) public class JsonUtils { /** * parseJson *

The parse json method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param target T

The target parameter is T type.

* @return {@link java.lang.String}

The parse json return object is String type.

* @see java.lang.String */ public static String parseJson(T target) { try { return JsonHelper.parseJson(target); } catch (JsonParseException exception) { log.error("It is failed during bean to parse as json! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseJson *

The parse json method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param target T

The target parameter is T type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return {@link java.lang.String}

The parse json return object is String type.

* @see com.fasterxml.jackson.core.type.TypeReference * @see java.lang.String */ public static String parseJson(T target, TypeReference typeReference) { try { return JsonHelper.parseJson(target,typeReference); } catch (JsonParseException exception) { log.error("It is failed during bean to parse as json with type reference! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseJsonIgnoreNull *

The parse json ignore null method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param target T

The target parameter is T type.

* @return {@link java.lang.String}

The parse json ignore null return object is String type.

* @see java.lang.String */ public static String parseJsonIgnoreNull(T target) { try { return JsonHelper.parseJsonIgnoreNull(target); } catch (JsonParseException exception) { log.error("It is failed during bean to parse as json with ignoring null! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseBean *

The parse bean method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return T

The parse bean return object is T type.

* @see java.lang.String * @see java.lang.Class */ public static T parseBean(String json, Class clazz) { try { return JsonHelper.parseBean(json, clazz); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as bean with class type! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseBean *

The parse bean method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return T

The parse bean return object is T type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference */ public static T parseBean(String json, TypeReference typeReference) { try { return JsonHelper.parseBean(json, typeReference); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as bean with type reference! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseBean *

The parse bean method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param javaType {@link com.fasterxml.jackson.databind.JavaType}

The java type parameter is JavaType type.

* @return T

The parse bean return object is T type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.JavaType */ public static T parseBean(String json, JavaType javaType) { try { return JsonHelper.parseBean(json, javaType); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as bean! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseBean *

The parse bean method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @param innerClazz {@link java.lang.Class}

The inner clazz parameter is Class type.

* @return T

The parse bean return object is T type.

* @see java.lang.String * @see java.lang.Class */ public static T parseBean(String json, Class clazz, Class innerClazz) { try { return JsonHelper.parseBean(json, clazz, innerClazz); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as bean! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseList *

The parse list method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param listType {@link com.fasterxml.jackson.databind.type.CollectionType}

The list type parameter is CollectionType type.

* @return {@link java.util.List}

The parse list return object is List type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.type.CollectionType * @see java.util.List */ public static List parseList(String json, CollectionType listType) { try { return JsonHelper.parseList(json, listType); } catch (JsonParseListException exception) { log.error("It is failed during json to parse as list of collection with collection type! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return Collections.emptyList(); } } /** * parseList *

The parse list method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return {@link java.util.List}

The parse list return object is List type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference * @see java.util.List */ public static List parseList(String json, TypeReference> typeReference) { try { return JsonHelper.parseList(json, typeReference); } catch (JsonParseListException exception) { log.error("It is failed during json to parse as list of collection! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return Collections.emptyList(); } } /** * parseList *

The parse list method.

* @param {@link java.util.List}

The generic parameter is List type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param parseClazz {@link java.lang.Class}

The parse clazz parameter is Class type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link java.util.List}

The parse list return object is List type.

* @see java.util.List * @see java.lang.String * @see java.lang.Class */ public static , T> List parseList(String json, Class parseClazz, Class clazz) { CollectionType listType = TypeFactory.defaultInstance().constructCollectionType(parseClazz, clazz); return parseList(json, listType); } /** * parseList *

The parse list method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link java.util.List}

The parse list return object is List type.

* @see java.lang.String * @see java.lang.Class * @see java.util.List */ public static List parseList(String json, Class clazz) { return parseList(json, List.class, clazz); } /** * parseSet *

The parse set method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param setType {@link com.fasterxml.jackson.databind.type.CollectionType}

The set type parameter is CollectionType type.

* @return {@link java.util.Set}

The parse set return object is Set type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.type.CollectionType * @see java.util.Set */ public static Set parseSet(String json, CollectionType setType) { try { return JsonHelper.parseSet(json, setType); } catch (JsonParseSetException exception) { log.error("It is failed during json to parse as set of collection with collection type! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return Collections.emptySet(); } } /** * parseSet *

The parse set method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return {@link java.util.Set}

The parse set return object is Set type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference * @see java.util.Set */ public static Set parseSet(String json, TypeReference> typeReference) { try { return JsonHelper.parseSet(json, typeReference); } catch (JsonParseSetException exception) { log.error("It is failed during json to parse as set of collection! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return Collections.emptySet(); } } /** * parseSet *

The parse set method.

* @param {@link java.util.Set}

The generic parameter is Set type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param parseClazz {@link java.lang.Class}

The parse clazz parameter is Class type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link java.util.Set}

The parse set return object is Set type.

* @see java.util.Set * @see java.lang.String * @see java.lang.Class */ public static , T> Set parseSet(String json, Class parseClazz, Class clazz) { CollectionType setType = TypeFactory.defaultInstance().constructCollectionType(parseClazz, clazz); return parseSet(json, setType); } /** * parseSet *

The parse set method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link java.util.Set}

The parse set return object is Set type.

* @see java.lang.String * @see java.lang.Class * @see java.util.Set */ public static Set parseSet(String json, Class clazz) { return parseSet(json, Set.class, clazz); } /** * parseMap *

The parse map method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param mapType {@link com.fasterxml.jackson.databind.type.MapType}

The map type parameter is MapType type.

* @return {@link java.util.Map}

The parse map return object is Map type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.type.MapType * @see java.util.Map */ public static Map parseMap(String json, MapType mapType) { try { return JsonHelper.parseMap(json, mapType); } catch (JsonParseMapException exception) { log.error("It is failed during json to parse as map of bean! {}", exception.getMessage(),exception); GeneralUtils.printStackTrace(exception); return Collections.emptyMap(); } } /** * parseMap *

The parse map method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return {@link java.util.Map}

The parse map return object is Map type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference * @see java.util.Map */ public static Map parseMap(String json, TypeReference> typeReference) { try { return JsonHelper.parseMap(json, typeReference); } catch (JsonParseMapException exception) { log.error("It is failed during json to parse as map of bean! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return Collections.emptyMap(); } } /** * parseArray *

The parse array method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param arrayType {@link com.fasterxml.jackson.databind.type.ArrayType}

The array type parameter is ArrayType type.

* @return T

The parse array return object is T type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.type.ArrayType */ public static T[] parseArray(String json, ArrayType arrayType) { try { return JsonHelper.parseArray(json, arrayType); } catch (JsonParseListException exception) { log.error("It is failed during json to parse as array of bean with array type! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseArray *

The parse array method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return T

The parse array return object is T type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference */ public static T[] parseArray(String json, TypeReference typeReference) { try { return JsonHelper.parseArray(json, typeReference); } catch (JsonParseListException exception) { log.error("It is failed during json to parse as array of bean! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseArray *

The parse array method.

* @param {@link java.util.List}

The generic parameter is List type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return T

The parse array return object is T type.

* @see java.util.List * @see java.lang.String * @see java.lang.Class */ public static , T> T[] parseArray(String json, Class clazz) { ArrayType arrayType = TypeFactory.defaultInstance().constructArrayType(clazz); return parseArray(json, arrayType); } /** * parseMap *

The parse map method.

* @param {@link java.util.Map}

The generic parameter is Map type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param parseClazz {@link java.lang.Class}

The parse clazz parameter is Class type.

* @param keyClazz {@link java.lang.Class}

The key clazz parameter is Class type.

* @param valueClazz {@link java.lang.Class}

The value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map return object is Map type.

* @see java.util.Map * @see java.lang.String * @see java.lang.Class */ public static , T, K> Map parseMap(String json, Class parseClazz, Class keyClazz, Class valueClazz) { MapType mapType = TypeFactory.defaultInstance().constructMapType(parseClazz, keyClazz, valueClazz); return parseMap(json, mapType); } /** * parseMap *

The parse map method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param keyClazz {@link java.lang.Class}

The key clazz parameter is Class type.

* @param valueClazz {@link java.lang.Class}

The value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map return object is Map type.

* @see java.lang.String * @see java.lang.Class * @see java.util.Map */ public static Map parseMap(String json, Class keyClazz, Class valueClazz) { return parseMap(json, Map.class, keyClazz, valueClazz); } /** * parseMapList *

The parse map list method.

* @param {@link java.util.List}

The generic parameter is List type.

* @param {@link java.util.Map}

The generic parameter is Map type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param parseListClazz {@link java.lang.Class}

The parse list clazz parameter is Class type.

* @param parseMapClazz {@link java.lang.Class}

The parse map clazz parameter is Class type.

* @param keyClazz {@link java.lang.Class}

The key clazz parameter is Class type.

* @param valueClazz {@link java.lang.Class}

The value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map list return object is Map type.

* @see java.util.List * @see java.util.Map * @see java.lang.String * @see java.lang.Class */ public static , Y extends Map, T, K> Map> parseMapList(String json, Class parseListClazz, Class parseMapClazz, Class keyClazz, Class valueClazz) { CollectionType collectionType = TypeFactory.defaultInstance().constructCollectionType(parseListClazz, valueClazz); MapType mapType = TypeFactory.defaultInstance().constructMapType(parseMapClazz, keyClazz, collectionType.getRawClass()); return parseMap(json, mapType); } /** * parseMapList *

The parse map list method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param keyClazz {@link java.lang.Class}

The key clazz parameter is Class type.

* @param valueClazz {@link java.lang.Class}

The value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map list return object is Map type.

* @see java.lang.String * @see java.lang.Class * @see java.util.Map */ public static Map> parseMapList(String json, Class keyClazz, Class valueClazz) { return parseMapList(json, List.class, Map.class, keyClazz, valueClazz); } /** * parseListMap *

The parse list map method.

* @param {@link java.util.List}

The generic parameter is List type.

* @param {@link java.util.Map}

The generic parameter is Map type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param wrapKeyClazz {@link java.lang.Class}

The wrap key clazz parameter is Class type.

* @param contentMapClazz {@link java.lang.Class}

The content map clazz parameter is Class type.

* @param contentKeyClazz {@link java.lang.Class}

The content key clazz parameter is Class type.

* @param contentValueClazz {@link java.lang.Class}

The content value clazz parameter is Class type.

* @return {@link java.util.List}

The parse list map return object is List type.

* @see java.util.List * @see java.util.Map * @see java.lang.String * @see java.lang.Class */ public static , Y extends Map, T, K> List> parseListMap(String json, Class wrapKeyClazz, Class contentMapClazz, Class contentKeyClazz, Class contentValueClazz) { MapType contentType = TypeFactory.defaultInstance().constructMapType(contentMapClazz, contentKeyClazz, contentValueClazz); CollectionType collectionType = TypeFactory.defaultInstance().constructCollectionType(wrapKeyClazz, contentType.getRawClass()); return parseList(json, collectionType); } /** * parseListMap *

The parse list map method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param contentKeyClazz {@link java.lang.Class}

The content key clazz parameter is Class type.

* @param contentValueClazz {@link java.lang.Class}

The content value clazz parameter is Class type.

* @return {@link java.util.List}

The parse list map return object is List type.

* @see java.lang.String * @see java.lang.Class * @see java.util.List */ public static List> parseListMap(String json, Class contentKeyClazz, Class contentValueClazz) { MapType contentType = TypeFactory.defaultInstance().constructMapType(Map.class, contentKeyClazz, contentValueClazz); CollectionType collectionType = TypeFactory.defaultInstance().constructCollectionType(List.class, contentType.getRawClass()); return parseList(json, collectionType); } /** * parseMapMap *

The parse map map method.

* @param {@link java.util.Map}

The generic parameter is Map type.

* @param {@link java.util.Map}

The generic parameter is Map type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param wrapMapClazz {@link java.lang.Class}

The wrap map clazz parameter is Class type.

* @param contentMapClazz {@link java.lang.Class}

The content map clazz parameter is Class type.

* @param wrapKeyClazz {@link java.lang.Class}

The wrap key clazz parameter is Class type.

* @param contentKeyClazz {@link java.lang.Class}

The content key clazz parameter is Class type.

* @param contentValueClazz {@link java.lang.Class}

The content value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map map return object is Map type.

* @see java.util.Map * @see java.lang.String * @see java.lang.Class */ public static , Y extends Map, Z, T, K> Map> parseMapMap(String json, Class wrapMapClazz, Class contentMapClazz, Class wrapKeyClazz, Class contentKeyClazz, Class contentValueClazz) { MapType contentType = TypeFactory.defaultInstance().constructMapType(contentMapClazz, contentKeyClazz, contentValueClazz); MapType mapType = TypeFactory.defaultInstance().constructMapType(wrapMapClazz, wrapKeyClazz, contentType.getRawClass()); return parseMap(json, mapType); } /** * parseMapMap *

The parse map map method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param wrapKeyClazz {@link java.lang.Class}

The wrap key clazz parameter is Class type.

* @param contentKeyClazz {@link java.lang.Class}

The content key clazz parameter is Class type.

* @param contentValueClazz {@link java.lang.Class}

The content value clazz parameter is Class type.

* @return {@link java.util.Map}

The parse map map return object is Map type.

* @see java.lang.String * @see java.lang.Class * @see java.util.Map */ public static Map> parseMapMap(String json, Class wrapKeyClazz, Class contentKeyClazz, Class contentValueClazz) { return parseMapMap(json, Map.class, Map.class, wrapKeyClazz, contentKeyClazz, contentValueClazz); } /** * parseResult *

The parse result method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param typeReference {@link com.fasterxml.jackson.core.type.TypeReference}

The type reference parameter is TypeReference type.

* @return {@link io.github.nichetoolkit.rest.RestResult}

The parse result return object is RestResult type.

* @see java.lang.String * @see com.fasterxml.jackson.core.type.TypeReference * @see io.github.nichetoolkit.rest.RestResult */ public static RestResult parseResult(String json, TypeReference typeReference) { JavaType javaType = TypeFactory.defaultInstance().constructType(typeReference); JavaType parametricType = TypeFactory.defaultInstance().constructParametricType(RestResult.class, javaType); try { return JsonHelper.parseResult(json, parametricType); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as type reference result of restResult! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseResult *

The parse result method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param javaType {@link com.fasterxml.jackson.databind.JavaType}

The java type parameter is JavaType type.

* @return {@link io.github.nichetoolkit.rest.RestResult}

The parse result return object is RestResult type.

* @see java.lang.String * @see com.fasterxml.jackson.databind.JavaType * @see io.github.nichetoolkit.rest.RestResult */ public static RestResult parseResult(String json, JavaType javaType) { try { return JsonHelper.parseResult(json, javaType); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as java type result of restResult! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseResult *

The parse result method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param json {@link java.lang.String}

The json parameter is String type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link io.github.nichetoolkit.rest.RestResult}

The parse result return object is RestResult type.

* @see java.lang.String * @see java.lang.Class * @see io.github.nichetoolkit.rest.RestResult */ public static RestResult parseResult(String json, Class clazz) { try { return JsonHelper.parseResult(json, clazz); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as clazz result of restResult! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseResult *

The parse result method.

* @param json {@link java.lang.String}

The json parameter is String type.

* @return {@link io.github.nichetoolkit.rest.RestResult}

The parse result return object is RestResult type.

* @see java.lang.String * @see io.github.nichetoolkit.rest.RestResult */ public static RestResult parseResult(String json) { try { return JsonHelper.parseResult(json); } catch (JsonParseBeanException exception) { log.error("It is failed during json to parse as result of restResult! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } /** * parseConvert *

The parse convert method.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @param value {@link java.lang.Object}

The value parameter is Object type.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return T

The parse convert return object is T type.

* @see java.lang.Object * @see java.lang.Class */ public static T parseConvert(Object value, Class clazz) { try { return JsonHelper.parseConvert(value, clazz); } catch (ClassUnsupportedException exception) { log.error("It is failed during object to convert as clazz of bean! {}", exception.getMessage()); GeneralUtils.printStackTrace(exception); return null; } } }