Class Jackson


  • public class Jackson
    extends Object
    Author:
    Yuriy Zabrovarnyy
    • Method Detail

      • asJsonNode

        public static com.fasterxml.jackson.databind.JsonNode asJsonNode​(String objAsString)
                                                                  throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • getElement

        public static String getElement​(String jsonString,
                                        String fieldName)
                                 throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • applyPatch

        public static <T> T applyPatch​(String patchAsString,
                                       T obj)
                                throws com.github.fge.jsonpatch.JsonPatchException,
                                       IOException
        Throws:
        com.github.fge.jsonpatch.JsonPatchException
        IOException
      • isFieldPresent

        public static boolean isFieldPresent​(String patchAsString,
                                             String fieldName)
      • getJsonPatch

        public static com.github.fge.jsonpatch.JsonPatch getJsonPatch​(String patchAsString)
                                                               throws com.github.fge.jsonpatch.JsonPatchException,
                                                                      IOException
        Throws:
        com.github.fge.jsonpatch.JsonPatchException
        IOException
      • applyJsonPatch

        public static <T> T applyJsonPatch​(com.github.fge.jsonpatch.JsonPatch jsonPatch,
                                           T obj)
                                    throws com.github.fge.jsonpatch.JsonPatchException,
                                           IOException
        Throws:
        com.github.fge.jsonpatch.JsonPatchException
        IOException
      • applyPatch

        public static <T> T applyPatch​(com.github.fge.jsonpatch.JsonPatch jsonPatch,
                                       T obj)
                                throws com.github.fge.jsonpatch.JsonPatchException,
                                       com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.github.fge.jsonpatch.JsonPatchException
        com.fasterxml.jackson.core.JsonProcessingException
      • createJsonMapper

        public static com.fasterxml.jackson.databind.ObjectMapper createJsonMapper()
      • readStringValue

        public static <T> T readStringValue​(String content,
                                            Class<T> clazz)
                                     throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • readListValue

        public static <T> List<T> readListValue​(String content,
                                                Class<T> clazz)
                                         throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • readList

        public static <T> List<T> readList​(String str,
                                           Class<T> type)
                                    throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • readList

        public static <T> List<T> readList​(String str,
                                           Class<? extends List> type,
                                           Class<T> elementType)
                                    throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
      • createJSONObject

        public static org.json.JSONObject createJSONObject​(Map<String,​Object> map)
                                                    throws org.json.JSONException
        Throws:
        org.json.JSONException
      • isValidJson

        public static boolean isValidJson​(String json)
      • isValidJson

        public static boolean isValidJson​(Object obj)
      • convertObjectToJsonObject

        public static org.json.JSONObject convertObjectToJsonObject​(Object obj)
                                                             throws com.fasterxml.jackson.core.JsonProcessingException
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException