Package com.google.gwt.json.client

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


    }
    if (isArray(object))
    {
      return new JSONArray(object);
    }
    return new JSONObject(object);
  }
View Full Code Here


                    String json = html;

                    if(!GWT.isScript()) // TODO: Formpanel weirdness
                        json = html.substring(html.indexOf(">")+1, html.lastIndexOf("<"));

                    JSONObject response  = JSONParser.parseLenient(json).isObject();
                    JSONObject result = response.get("result").isObject();
                    String hash= result.get("BYTES_VALUE").isString().stringValue();
                    // step2: assign name and group
                    wizard.onUploadComplete(upload.getFilename(), hash);

                } catch (Exception e) {
                    Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
View Full Code Here

                        // if I get this exception it means I shouldn't strip out the html
                        // this issue still needs more research
                        Log.debug("Failed to strip out HTML.  This should be preferred?");
                    }

                    JSONObject response  = JSONParser.parseLenient(json).isObject();
                    JSONObject result = response.get("result").isObject();
                    String hash= result.get("BYTES_VALUE").isString().stringValue();
                    // step2: assign name and group
                    wizard.onUploadComplete(upload.getFilename(), hash);

                } catch (Exception e) {
                    Log.error(Console.CONSTANTS.common_error_failedToDecode() + ": " + html, e);
View Full Code Here

        Key<?, ?> k = parseNamespacedKey(em, key, false);
        if (k == null) return;
        logger.trace("getAll(): considering " + value);
        if (type.isSuperclassOf(k.getEntityType())) {
          logger.trace(" --> correct type");
          JSONObject candidate = JSONParser.parseStrict(value).isObject();
          Assert.notNull(candidate);
          if (matcher.matches(candidate)) {
            @SuppressWarnings("unchecked")
            Key<X, ?> typedKey = (Key<X, ?>) k;
View Full Code Here

   */
  public abstract X fromJson(EntityManager em, JSONValue jsonValue);

  public JSONValue toJson(EntityManager em, X sourceEntity) {
    final ErraiEntityManager eem = (ErraiEntityManager) em;
    JSONObject jsonValue = new JSONObject();

    for (Attribute<? super X, ?> a : getAttributes()) {
      ErraiAttribute<? super X, ?> attr = (ErraiAttribute<? super X, ?>) a;
      switch (attr.getPersistentAttributeType()) {
      case ELEMENT_COLLECTION:
      case EMBEDDED:
      case BASIC:
        jsonValue.put(attr.getName(), makeInlineJson(sourceEntity, attr, eem));
      break;

      case MANY_TO_MANY:
      case MANY_TO_ONE:
      case ONE_TO_MANY:
      case ONE_TO_ONE:
        JSONValue attributeValue;
        if (attr instanceof ErraiSingularAttribute) {
          attributeValue = makeJsonReference(sourceEntity, (ErraiSingularAttribute<? super X, ?>) attr, eem);
        }
        else if (attr instanceof ErraiPluralAttribute) {
          attributeValue = makeJsonReference(sourceEntity, (ErraiPluralAttribute<? super X, ?, ?>) attr, eem);
        }
        else {
          throw new PersistenceException("Unknown attribute type " + attr);
        }
        jsonValue.put(attr.getName(), attributeValue);
      }
    }

    return jsonValue;
  }
View Full Code Here

   *
   * @see #toJson()
   * @return a JSON object that represents this key. Never null.
   */
  public JSONObject toJsonObject() {
    JSONObject keyJson = new JSONObject();
    keyJson.put("entityType", new JSONString(entityType.getJavaType().getName()));
    keyJson.put("id", JsonUtil.basicValueToJson(id));
    return keyJson;
  }
View Full Code Here

        return marshallerFactory.getMarshaller(null, fqcn);
      }

      @Override
      public String determineTypeFor(String formatType, Object o) {
        JSONObject jsonObject = (JSONObject) o;
        return jsonObject.get(SerializationParts.ENCODED_TYPE).isString().stringValue();
      }
    };

    Marshaller<Object, Object> marshaller =
            marshallerFactory.getMarshaller(null, context.determineTypeFor(null, object));
View Full Code Here

        this.label = label;
    }

    public void onCompletion(String responseText) {
        JSONValue jsonValue = JSONParser.parse(responseText);
        JSONObject jsonObject = jsonValue.isObject();

        if (jsonObject != null){
            JSONValue feedValue = jsonObject.get("feed");
            if (feedValue != null && feedValue.isObject() != null){
                JSONObject feedObject = feedValue.isObject();
                    JSONValue entryObject = feedObject.get("entry");
                    if (entryObject != null && entryObject.isArray() != null){
                        JSONArray entryArray = entryObject.isArray();
                        for(int i=0; i < entryArray.size(); i++){
                            JSONValue entryValue = entryArray.get(i);
                            if (entryValue != null && entryValue.isObject() != null){
                                JSONValue cell = entryValue.isObject().get("gs$cell");
                                JSONObject cellObject = cell.isObject();
                                System.out.println("cellObject = " + cellObject);
                                JSONValue cellStr = cellObject.get("$t");
                                System.out.println("cellStr = " + cellStr);
                                label.setText(cellStr.toString());
                            }
                        }
                    }
View Full Code Here

                         @Nonnull final RequestCallback callback) {
        String json = null;
        if (remoteSettings != null) {

            // TODO add appropriate comment - wrap 
            JSONObject rootElement = new JSONObject();
            rootElement.put(SETTINGS_KEY, new JSONObject(remoteSettings));
            json = rootElement.toString();
        }

        try {
            builder.sendRequest(json, callback);
        } catch (RequestException ex) {
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();
                }
            }
View Full Code Here

TOP

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

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.