Example usage for com.liferay.portal.kernel.json JSONDeserializer use

List of usage examples for com.liferay.portal.kernel.json JSONDeserializer use

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.json JSONDeserializer use.

Prototype

public JSONDeserializer<T> use(String path, Class<?> clazz);

Source Link

Usage

From source file:com.liferay.jsonwebserviceclient.BaseJSONWebServiceClientHandler.java

License:Open Source License

protected <T> List<T> doGetToList(Class<T> clazz, String url, String... parametersArray) throws Exception {

    String json = doGet(url, parametersArray);

    if ((json == null) || json.equals("{}") || json.equals("[]")) {
        return Collections.emptyList();
    }/*  w ww . ja v  a 2 s  . c om*/

    if (json.contains("exception")) {
        throw new Exception(getExceptionMessage(json));
    }

    JSONDeserializer<List<T>> jsonDeserializer = JSONFactoryUtil.createJSONDeserializer();

    jsonDeserializer.use("values", clazz);

    return jsonDeserializer.deserialize(json);
}