Example usage for com.google.gwt.json.client JSONValue isObject

List of usage examples for com.google.gwt.json.client JSONValue isObject

Introduction

In this page you can find the example usage for com.google.gwt.json.client JSONValue isObject.

Prototype

public JSONObject isObject() 

Source Link

Document

Returns non-null if this JSONValue is really a JSONObject.

Usage

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

public Map<String, OutputData> decodeOutputs(JSONValue json) throws FormEncodingException {
    Map<String, OutputData> retval = new HashMap<String, OutputData>();
    if (json != null && json.isObject() != null) {
        for (String key : json.isObject().keySet()) {
            JSONValue value = json.isObject().get(key);
            if (value.isObject() != null) {
                JSONObject jsonObj = value.isObject();
                retval.put(key, (OutputData) decode(asMap(jsonObj)));
            }//from  w  w w. j a  v a  2s .  c  om
        }
    }
    return retval;
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

public List<FBScript> decodeScripts(JSONValue json) throws FormEncodingException {
    List<FBScript> retval = new ArrayList<FBScript>();
    if (json != null && json.isArray() != null) {
        JSONArray array = json.isArray();
        for (int index = 0; index < array.size(); index++) {
            JSONValue elem = array.get(index);
            JSONObject jsonObj = elem.isObject();
            retval.add((FBScript) decode(asMap(jsonObj)));
        }/*  ww w  . j a v a 2 s  . c  om*/
    }
    return retval;
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

public List<FormItemRepresentation> decodeItems(JSONValue json) throws FormEncodingException {
    List<FormItemRepresentation> retval = new ArrayList<FormItemRepresentation>();
    if (json != null && json.isArray() != null) {
        JSONArray array = json.isArray();
        for (int index = 0; index < array.size(); index++) {
            JSONValue elem = array.get(index);
            JSONObject jsonObj = elem.isObject();
            retval.add((FormItemRepresentation) decode(asMap(jsonObj)));
        }// w w w  .  ja  va  2 s . com
    }
    return retval;
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

public List<FBValidation> decodeValidations(JSONValue json) throws FormEncodingException {
    List<FBValidation> retval = new ArrayList<FBValidation>();
    if (json != null && json.isArray() != null) {
        JSONArray array = json.isArray();
        for (int index = 0; index < array.size(); index++) {
            JSONValue elem = array.get(index);
            JSONObject jsonObj = elem.isObject();
            retval.add((FBValidation) decode(asMap(jsonObj)));
        }//from   w w  w . j  a va2  s  .  c  om
    }
    return retval;
}

From source file:org.jbpm.formapi.client.form.FormRepresentationDecoderClient.java

License:Apache License

private Object fromJsonValue(JSONValue elem) {
    if (elem.isString() != null) {
        return elem.isString().stringValue();
    } else if (elem.isNumber() != null) {
        return elem.isNumber().doubleValue();
    } else if (elem.isArray() != null) {
        return asList(elem.isArray());
    } else if (elem.isNull() != null) {
        return null;
    } else if (elem.isObject() != null) {
        return asMap(elem.isObject());
    } else {/*from   ww w.ja  va2 s . c o  m*/
        return "";
    }
}

From source file:org.jbpm.formbuilder.client.JsonLoadInput.java

License:Apache License

public static JsonLoadInput parse(String innerHTML) throws FormEncodingException {
    JSONValue json = JSONParser.parseStrict(innerHTML);
    JsonLoadInput input = null;//w w  w . j  a va  2 s .c o  m
    if (json.isObject() != null) {
        input = new JsonLoadInput();
        JSONObject jsonObj = json.isObject();
        if (jsonObj.get("embedded") != null && jsonObj.get("embedded").isString() != null) {
            input.setProfile(jsonObj.get("embedded").isString().stringValue());
        }
        JSONValue jsonPkg = jsonObj.get("packageName");
        if (jsonPkg != null && jsonPkg.isString() != null) {
            input.setPackage(jsonPkg.isString().stringValue());
        }
        JSONValue jsonCtx = jsonObj.get("contextPath");
        if (jsonCtx != null && jsonCtx.isString() != null) {
            input.setContextPath(jsonCtx.isString().stringValue());
        }
        if (jsonObj.get("task") != null && jsonObj.get("task").isObject() != null) {
            input.setTask(toTask(jsonObj.get("task").isObject()));
        }
        if (jsonObj.get("formData") != null && jsonObj.get("formData").isObject() != null) {
            input.setFormData(toFormData(jsonObj.get("formData").isObject()));
        }
        if (jsonObj.get("formjson") != null && jsonObj.get("formjson").isString() != null) {
            input.setForm(toForm(jsonObj.get("formjson").isString().stringValue()));
        }
    }
    return input;
}

From source file:org.jbpm.formbuilder.client.JsonLoadInput.java

License:Apache License

private static Object asActualValue(JSONValue value) {
    if (value.isArray() != null) {
        JSONArray arr = value.isArray();
        List<Object> retval = new ArrayList<Object>();
        for (int index = 0; index < arr.size(); index++) {
            JSONValue subValue = arr.get(index);
            retval.add(asActualValue(subValue));
        }//from ww  w.j a v  a  2 s.  c o  m
        return retval;
    } else if (value.isBoolean() != null) {
        return String.valueOf(value.isBoolean().booleanValue());
    } else if (value.isNull() != null) {
        return null;
    } else if (value.isNumber() != null) {
        return String.valueOf(value.isNumber().doubleValue());
    } else if (value.isString() != null) {
        return value.isString().stringValue();
    } else if (value.isObject() != null) {
        return toFormData(value.isObject());
    }
    return null;
}

From source file:org.krypsis.gwt.store.client.javascript.JsStore.java

License:MIT License

/**
 * Loads the object that contains all instances.
 *
 * @return The JSON Object that contains all saved instance
 *//*from  www.  j  a  v a 2s  .co m*/
private JSONObject loadObject() {
    final String data = backend.get(key.getName());

    JSONObject object;
    if (data == null) {
        object = new JSONObject();
    } else {
        final JSONValue jsonValue = JSONParser.parse(data);
        object = jsonValue.isObject();
    }

    if (object == null) {
        throw new IllegalArgumentException("Database is broken. Array could not been deserialized");
    }

    return object;
}

From source file:org.lirazs.gbackbone.client.core.collection.Collection.java

License:Apache License

public List<T> parse(JSONValue resp, Options options) {
    List<T> result = new ArrayList<T>();
    JSONArray array = resp != null && resp.isArray() != null ? resp.isArray() : new JSONArray();

    if (resp != null && resp.isObject() != null) {
        array.set(0, resp.isObject());/*  www .  jav  a 2  s .  co m*/
    }
    if (options == null)
        options = new Options();

    for (int i = 0; i < array.size(); i++) {
        JSONValue jsonValue = array.get(i);
        if (jsonValue != null && jsonValue.isObject() != null) {
            T model = prepareModel(jsonValue.isObject(), options);
            if (model != null) {
                result.add(model);
            }
        }
    }

    return result;
}

From source file:org.lirazs.gbackbone.client.core.data.Options.java

License:Apache License

public Options(JSONValue jsonObject) {
    JSONObject object = jsonObject.isObject();

    if (object != null) {
        for (String s : object.keySet()) {
            JSONValue jsonValue = object.get(s);
            Object value = jsonValue;

            JSONNumber number = jsonValue.isNumber();
            if (number != null) {
                if (number.toString().contains(".")) {
                    value = number.doubleValue();
                } else {
                    value = (int) number.doubleValue();
                }//  w ww  .jav a 2  s .  com
            }

            JSONBoolean jsonBoolean = jsonValue.isBoolean();
            if (jsonBoolean != null)
                value = jsonBoolean.booleanValue();

            JSONNull jsonNull = jsonValue.isNull();
            if (jsonNull != null)
                value = null;

            JSONString jsonString = jsonValue.isString();
            if (jsonString != null)
                value = jsonString.stringValue();

            put(s, value);
        }
    }
}