public class JSONUtils
extends java.lang.Object
构造器和说明 |
---|
JSONUtils() |
限定符和类型 | 方法和说明 |
---|---|
static org.json.JSONObject |
cloneJsonObject(org.json.JSONObject jsonObject)
clone new JSONObject
|
static java.lang.String |
formatJson(java.lang.String jsonStr) |
static boolean |
isJson(java.lang.String str) |
static java.util.Map<java.lang.String,java.lang.String> |
json2Map(org.json.JSONObject json) |
static void |
mergeDistinctProperty(org.json.JSONObject source,
org.json.JSONObject dest)
merge distinct property
|
static void |
mergeDuplicateProperty(org.json.JSONObject source,
org.json.JSONObject dest)
合并 dest 中包含 source 相同的 key 属性
|
static void |
mergeJSONObject(org.json.JSONObject source,
org.json.JSONObject dest) |
static org.json.JSONObject |
mergeSuperJSONObject(org.json.JSONObject source,
org.json.JSONObject dest)
合并、去重公共属性
|
static java.lang.String |
optionalStringKey(org.json.JSONObject o,
java.lang.String k) |
public static java.lang.String optionalStringKey(org.json.JSONObject o, java.lang.String k) throws org.json.JSONException
org.json.JSONException
public static java.lang.String formatJson(java.lang.String jsonStr)
public static java.util.Map<java.lang.String,java.lang.String> json2Map(org.json.JSONObject json)
public static void mergeDistinctProperty(org.json.JSONObject source, org.json.JSONObject dest)
source
- Sourcedest
- Targetpublic static void mergeDuplicateProperty(org.json.JSONObject source, org.json.JSONObject dest)
source
- JSONObjectdest
- JSONObjectpublic static org.json.JSONObject cloneJsonObject(org.json.JSONObject jsonObject) throws InvalidDataException
jsonObject
- SourceInvalidDataException
- DataExceptionpublic static void mergeJSONObject(org.json.JSONObject source, org.json.JSONObject dest)
public static org.json.JSONObject mergeSuperJSONObject(org.json.JSONObject source, org.json.JSONObject dest)
source
- 新加入或者优先级高的属性dest
- 本地缓存或者优先级低的属性,如果有重复会删除该属性public static boolean isJson(java.lang.String str)