Package com.google.gwt.json.client

Examples of com.google.gwt.json.client.JSONValue


        Long value = getLong(object, key);
        return value == null ? defaultValue : value;
    }

    public static Float getFloat(JSONObject object, String key) {
        JSONValue value = object.get(key);
        return value == null || value.isNull() != null ? null : (float) value.isNumber().doubleValue();
    }
View Full Code Here


        Float value = getFloat(object, key);
        return value == null ? defaultValue : value;
    }

    public static Double getDouble(JSONObject object, String key) {
        JSONValue value = object.get(key);
        return value == null || value.isNull() != null ? null : value.isNumber().doubleValue();
    }
View Full Code Here

        Double value = getDouble(object, key);
        return value == null ? defaultValue : value;
    }

    public static String getString(JSONObject object, String key) {
        JSONValue value = object.get(key);
        if (value == null || value.isNull() != null) {
            return  null;
        }
        if (value.isString() == null) {
            throw new RuntimeException("Expected string value for key [" + key + "] but found '" + String.valueOf(value) + "' instead");
        }
        return  value.isString().stringValue();
    }
View Full Code Here

        String value = getString(object, key);
        return value == null ? defaultValue : value;
    }

    public static JSONObject getObject(JSONObject object, String key) {
        JSONValue value = object.get(key);
        return value == null || value.isNull() != null ? null : value.isObject();
    }
View Full Code Here

        JSONValue value = object.get(key);
        return value == null || value.isNull() != null ? null : value.isObject();
    }

    public static JSONArray getArray(JSONObject object, String key) {
        JSONValue value = object.get(key);
        return value == null || value.isNull() != null ? null : value.isArray();
    }
View Full Code Here

            RemoteSettings result = null;

            if (response.getText() != null && !"".equals(response.getText())) {

                // TODO add appropriate comment - unwrap
                JSONValue rootElement = new JSONObject(convertFromJSON(response.getText())).get(SETTINGS_KEY);
                if (rootElement != null && rootElement.isObject() != null) {
                    result = (RemoteSettings) rootElement.isObject().getJavaScriptObject();
                }
            }

            return result != null ? Converter.convertToSettings(result) : null;
        }
View Full Code Here

   */
  public Object decode(String json) {
    if (json == null)
      throw new RuntimeException("Json string must not be null.");
    try {
      JSONValue value = JSONParser.parse(json);
      Object jsonObject = buildJavaObjectFromJSONValue(value);
      return jsonObject;
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
View Full Code Here

    private Label errorMsgLabel = new Label();
   
  void parseJSON(Response response, MultiWordSuggestOracle o) {
    //JavaScriptObject jso = parseJson(responseJSON);
    System.out.println("Got some JSON");
    JSONValue val = JSONParser.parseStrict(response.getText());
    JSONObject ob = val.isObject();
    JSONValue value = null;
   
    if (type == "name_first") {
      value = ob.get("firstName");
    }
    else if (type == "name_last") {
      value = ob.get("lastName");
    }
   
    JSONArray a = value.isArray();
    //System.out.println("printing last name" + a.get(0));
    o.clear();
    for (int i=0; i<a.size(); i++) {
      o.add(a.get(i).isString().stringValue());
      //System.out.println("adding: " + a.get(i));
View Full Code Here

          System.out.println("Couldn't retrieve JSON");
        }
    }
   
    void parseBloomJSON(Response response) {
      JSONValue val = JSONParser.parseStrict(response.getText());
      JSONObject ob = val.isObject();
      JSONValue value = null;
      value = ob.get("Exists");
      if (value.isBoolean().booleanValue()) {
        //RootPanel.get("existsContainer").clear();
        //RootPanel.get("existsContainer").add(new Label("(name exists)"));
        sendButton.setEnabled(true);
        sendButton.setText("found matches, go get them");
        //RootPanel.get("existsContainer").setVisible(true);
View Full Code Here

//  public static native JavaScriptObject parseJson(String jsonStr) /*-{
//    return eval(jsonStr);}-*/;
 
  void parseJSON(Response response, FlexTable f) {
    System.out.println("Got some search record results JSON");
    JSONValue val = JSONParser.parseStrict(response.getText());
    JSONObject ob = val.isObject();
    JSONValue value = null;
    value = ob.get("records");   
    JSONArray a = value.isArray();
    final int HEADER_ROW_INDEX = 0;

    f.insertRow(HEADER_ROW_INDEX);
    f.setWidget(HEADER_ROW_INDEX, 0, new Label("First Name"));
    f.setWidget(HEADER_ROW_INDEX, 1, new Label("Last Name"));
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.