Example usage for com.google.gwt.core.client JsonUtils safeEval

List of usage examples for com.google.gwt.core.client JsonUtils safeEval

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsonUtils safeEval.

Prototype

public static native <T extends JavaScriptObject> T safeEval(String json) ;

Source Link

Document

Evaluates a JSON expression safely.

Usage

From source file:org.turbogwt.net.serialization.client.json.OverlaySerdes.java

License:Apache License

@Override
public T deserialize(String response, DeserializationContext context) {
    return JsonUtils.safeEval(response);
}

From source file:org.turbogwt.net.serialization.client.json.OverlaySerdes.java

License:Apache License

@Override
@SuppressWarnings("unchecked")
public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response,
        DeserializationContext context) {
    JsArray<T> jsArray = JsonUtils.safeEval(response);
    if (collectionType.equals(List.class) || collectionType.equals(Collection.class)) {
        return (C) new JsArrayList(jsArray);
    } else {//from  w w  w.  j  a v a2 s. com
        C col = context.getContainerInstance(collectionType);
        for (int i = 0; i < jsArray.length(); i++) {
            T t = jsArray.get(i);
            col.add(t);
        }
        return col;
    }
}

From source file:ywb.c.model.PhotoMap.java

License:Apache License

public static HashMap<String, Photo> getStorageMap(Storage storage, Key key) {
    Log.info("::getFromStorage");
    String json = storage.getItem(key.getName());
    HashMap map = new HashMap<String, Photo>();
    if (json == null || json.trim().length() < 1) {
        return map;
    }// www  .j a v a  2s .  com
    JsArray<? extends JavaScriptObject> j = JsonUtils.safeEval(json);
    ArrayList<Photo> data = JsUtils.toArray(j);
    for (Photo u : data) {
        map.put(u.getUrl(), u);
    }
    return map;
}