Class JSONUtils

  • All Implemented Interfaces:

    
    public class JSONUtils
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONUtils()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static HashMap<String, MessageExpansion> jsonToExpansionEx(String originJson) Converts a JSON string into a HashMap<String, MessageExpansion> object MessageExpansion
      static HashMap<String, String> expansionExToMap(Map<String, MessageExpansion> map) Converts Map<String, MessageExpansion> to HashMap<String, String>MessageExpansion
      static String mapTsCombineJson(Map<String, String> map, long ts) Assembles the user-defined Map collection and timestamp into a JSON string
      static String exMapToJson(HashMap<String, MessageExpansion> hashMap) Parses the HashMap<String, MessageExpansion> object into a JSON string.
      static List<Object> removeKeysInExpansionEx(List<String> arrayList, HashMap<String, MessageExpansion> hashMap) Deletes the specified keys
      static List<Object> removeKeysTSInExpansionEx(long time, List<String> arrayList, HashMap<String, MessageExpansion> hashMap) Deletes the specified keys with timestamp comparison
      static HashMap<String, String> expansionExJSONToMap(String jsonString) Converts a JSON string into a HashMap<String, String>
      static String hashMapToJson(Map<String, String> map) Converts Map<String, String> map into a JSON string in the format: key1:{ v:value1 }
      static List<String> mergeJson(String expansionJsonSet, String expansionExisted) Merges two JSON strings with timestamps
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JSONUtils

        JSONUtils()
    • Method Detail

      • jsonToExpansionEx

         static HashMap<String, MessageExpansion> jsonToExpansionEx(String originJson)

        Converts a JSON string into a HashMap<String, MessageExpansion> object MessageExpansion

        Parameters:
        originJson - The original JSON string
        Returns:

        HashMap<String, MessageExpansion>MessageExpansion

      • expansionExToMap

         static HashMap<String, String> expansionExToMap(Map<String, MessageExpansion> map)

        Converts Map<String, MessageExpansion> to HashMap<String, String>MessageExpansion

        Parameters:
        map - Map<String, MessageExpansion>
        Returns:

        HashMap<String, String>

      • mapTsCombineJson

         static String mapTsCombineJson(Map<String, String> map, long ts)

        Assembles the user-defined Map collection and timestamp into a JSON string

        Parameters:
        map - Map
        ts - Timestamp
        Returns:

        String

      • exMapToJson

         static String exMapToJson(HashMap<String, MessageExpansion> hashMap)

        Parses the HashMap<String, MessageExpansion> object into a JSON string.

        Parameters:
        hashMap - HashMap<String, MessageExpansion>
        Returns:

        The JSON string

      • removeKeysInExpansionEx

         static List<Object> removeKeysInExpansionEx(List<String> arrayList, HashMap<String, MessageExpansion> hashMap)

        Deletes the specified keys

        Parameters:
        arrayList - The collection of keys to be deleted
        hashMap - HashMap<String, MessageExpansion>
        Returns:

        Full and incremental data after deletion

      • removeKeysTSInExpansionEx

         static List<Object> removeKeysTSInExpansionEx(long time, List<String> arrayList, HashMap<String, MessageExpansion> hashMap)

        Deletes the specified keys with timestamp comparison

        Parameters:
        arrayList - The collection of keys to be deleted
        hashMap - HashMap<String, MessageExpansion>
        Returns:

        Full and incremental data after deletion

      • expansionExJSONToMap

         static HashMap<String, String> expansionExJSONToMap(String jsonString)

        Converts a JSON string into a HashMap<String, String>

        Parameters:
        jsonString - The JSON string
        Returns:

        HashMap<String, String>

      • hashMapToJson

         static String hashMapToJson(Map<String, String> map)

        Converts Map<String, String> map into a JSON string in the format: key1:{ v:value1 }

        Parameters:
        map - Map<String, String> map
        Returns:

        JSON string

      • mergeJson

         static List<String> mergeJson(String expansionJsonSet, String expansionExisted)

        Merges two JSON strings with timestamps

        Parameters:
        expansionJsonSet - String
        expansionExisted - String
        Returns:

        Merged full and incremental data