Class JSONUtils
-
- All Implemented Interfaces:
public class JSONUtils
-
-
Constructor Summary
Constructors Constructor Description JSONUtils()
-
Method Summary
Modifier and Type Method Description static HashMap<String, MessageExpansion>jsonToExpansionEx(String originJson)Converts a JSON string into a HashMap<String, MessageExpansion>object MessageExpansionstatic HashMap<String, String>expansionExToMap(Map<String, MessageExpansion> map)Converts Map<String, MessageExpansion>toHashMap<String, String>MessageExpansionstatic StringmapTsCombineJson(Map<String, String> map, long ts)Assembles the user-defined Map collection and timestamp into a JSON string static StringexMapToJson(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 StringhashMapToJson(Map<String, String> map)Converts Map<String, String> mapinto a JSON string in the format: key1:{ v:value1 }static List<String>mergeJson(String expansionJsonSet, String expansionExisted)Merges two JSON strings with timestamps -
-
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>toHashMap<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- Mapts- 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 deletedhashMap-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 deletedhashMap-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> mapinto 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- StringexpansionExisted- String- Returns:
Merged full and incremental data
-
-
-
-