Class JSONUtils
java.lang.Object
org.opencastproject.index.service.util.JSONUtils
Utility class providing helpers for all operation related to JSON.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.google.gson.JsonArrayarrayToJsonArray(T[] array) static com.google.gson.JsonArraycollectionToJsonArray(Collection<?> collection) Turn a collection into aJsonArraystatic com.google.gson.JsonObjectfiltersToJSON(ResourceListQuery query, ListProvidersService listProvidersService, Organization org) Generate JSON presentation of the given filtersstatic com.google.gson.JsonObjectfiltersToJSONSeriesWriteAccess(ResourceListQuery query, ListProvidersService listProvidersService, Map<String, String> series) Generate JSON presentation of the given filtersstatic org.codehaus.jettison.json.JSONObjectReturns a JSON object with key-value from given mapstatic com.google.gson.JsonObjectmapToJsonObject(Map<?, ?> map) Turn a map into aJsonObjectobjectstatic StringsafeString(Object input) static voidsetUserRegex(String regex) toMap(org.codehaus.jettison.json.JSONObject json) Converts a JSON object to a map.
-
Method Details
-
safeString
-
collectionToJsonArray
Turn a collection into aJsonArray- Parameters:
collection- the collection- Returns:
- a new
JsonArraygenerated with the colleciton values
-
arrayToJsonArray
public static <T> com.google.gson.JsonArray arrayToJsonArray(T[] array) -
mapToJsonObject
Turn a map into aJsonObjectobject- Parameters:
map- the source map- Returns:
- a new
JsonObjectgenerated with the map values
-
filtersToJSON
public static com.google.gson.JsonObject filtersToJSON(ResourceListQuery query, ListProvidersService listProvidersService, Organization org) throws ListProviderException Generate JSON presentation of the given filters- Parameters:
query- TheResourceListQuerylistProvidersService- TheListProvidersServiceto get the possible valuesorg- TheOrganization- Returns:
- Throws:
ListProviderException- if the possible values can not be retrieved correctly from the list provider.
-
filtersToJSONSeriesWriteAccess
public static com.google.gson.JsonObject filtersToJSONSeriesWriteAccess(ResourceListQuery query, ListProvidersService listProvidersService, Map<String, String> series) throws ListProviderExceptionGenerate JSON presentation of the given filters- Parameters:
query- TheResourceListQuerylistProvidersService- TheListProvidersServiceto get the possible valuesseries- The Series with write access- Returns:
- Throws:
ListProviderException- if the possible values can not be retrieved correctly from the list provider.
-
fromMap
public static org.codehaus.jettison.json.JSONObject fromMap(Map<String, String> map) throws org.codehaus.jettison.json.JSONExceptionReturns a JSON object with key-value from given map- Parameters:
map- The source list for the JSON object- Returns:
- a JSON object containing the all the key-value as parameter
- Throws:
org.codehaus.jettison.json.JSONException
-
toMap
Converts a JSON object to a map. All values are of typeString- Parameters:
json- the JSON object to convert- Returns:
- the map
-
setUserRegex
-