org.skyscreamer.jsonassert.comparator
Class JSONCompareUtil

java.lang.Object
  extended by org.skyscreamer.jsonassert.comparator.JSONCompareUtil

public final class JSONCompareUtil
extends Object

Utility class that contains Json manipulation methods


Method Summary
static boolean allJSONArrays(org.json.JSONArray array)
           
static boolean allJSONObjects(org.json.JSONArray array)
           
static boolean allSimpleValues(org.json.JSONArray array)
           
static Map<Object,org.json.JSONObject> arrayOfJsonObjectToMap(org.json.JSONArray array, String uniqueKey)
           
static String findUniqueKey(org.json.JSONArray expected)
           
static String formatUniqueKey(String key, String uniqueKey, Object value)
           
static Set<String> getKeys(org.json.JSONObject jsonObject)
           
static boolean isSimpleValue(Object o)
           
static boolean isUsableAsUniqueKey(String candidate, org.json.JSONArray array)
          candidate is usable as a unique key if every element in the array is a JSONObject having that key, and no two values are the same.
static List<Object> jsonArrayToList(org.json.JSONArray expected)
           
static String qualify(String prefix, String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arrayOfJsonObjectToMap

public static Map<Object,org.json.JSONObject> arrayOfJsonObjectToMap(org.json.JSONArray array,
                                                                     String uniqueKey)
                                                              throws org.json.JSONException
Throws:
org.json.JSONException

findUniqueKey

public static String findUniqueKey(org.json.JSONArray expected)
                            throws org.json.JSONException
Throws:
org.json.JSONException

isUsableAsUniqueKey

public static boolean isUsableAsUniqueKey(String candidate,
                                          org.json.JSONArray array)
                                   throws org.json.JSONException
candidate is usable as a unique key if every element in the array is a JSONObject having that key, and no two values are the same.

Throws:
org.json.JSONException

jsonArrayToList

public static List<Object> jsonArrayToList(org.json.JSONArray expected)
                                    throws org.json.JSONException
Throws:
org.json.JSONException

allSimpleValues

public static boolean allSimpleValues(org.json.JSONArray array)
                               throws org.json.JSONException
Throws:
org.json.JSONException

isSimpleValue

public static boolean isSimpleValue(Object o)

allJSONObjects

public static boolean allJSONObjects(org.json.JSONArray array)
                              throws org.json.JSONException
Throws:
org.json.JSONException

allJSONArrays

public static boolean allJSONArrays(org.json.JSONArray array)
                             throws org.json.JSONException
Throws:
org.json.JSONException

getKeys

public static Set<String> getKeys(org.json.JSONObject jsonObject)

qualify

public static String qualify(String prefix,
                             String key)

formatUniqueKey

public static String formatUniqueKey(String key,
                                     String uniqueKey,
                                     Object value)


Copyright © 2013. All Rights Reserved.