Package com.google.gwt.json.client

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


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


  {
    if (jsonValue.isNull() != null)
    {
      return null;
    }
    JSONArray jsonArray = jsonValue.isArray();
    if (jsonArray != null)
    {
      return jsonArray.getJavaScriptObject();
    }
    return jsonValue.isObject().getJavaScriptObject();
  }
View Full Code Here

    ErraiIdentifiableType<E> attrEntityType = eem.getMetamodel().entity(attributeType);
    if (attrEntityType == null) {
      throw new IllegalArgumentException("Can't make a reference to collection of non-entity-typed attributes " + attr);
    }

    JSONArray array = new JSONArray();
    int index = 0;
    for (E element : (Iterable<E>) attrValue) {
      Object idToReference = attrEntityType.getId(Object.class).get(element);
      JSONValue ref;
      if (idToReference == null) {
        ref = JSONNull.getInstance();
      }
      else {
        // XXX attrEntityType is incorrect for collection elements that are subtypes of the attrEntityType
        ref = new Key<E, Object>(attrEntityType, idToReference).toJsonObject();
      }
      array.set(index++, ref);
    }
    return array;
  }
View Full Code Here

    }

    if (val == null) {
      return Collections.emptyList();
    }
    JSONArray arr = val.isArray();
    if (arr == null) {
      throw new RuntimeException("unrecognized payload" + val.toString());
    }
    ArrayList<MarshalledMessage> list = new ArrayList<MarshalledMessage>();
    unwrap(list, arr);
View Full Code Here

            @Override
            public void onSelectionChange(final SelectionChangeEvent event) {
                code.clear();
                AuditLogItem item = selectionModel.getSelectedObject();
                if (item != null) {
                    JSONArray jsonArray = JSONParser.parseStrict(item.getOperations().getPayload()).isArray();
                    if (jsonArray != null) {
                        String stringify = stringify(jsonArray.getJavaScriptObject());
                        code.setValue(SafeHtmlUtils.fromString(stringify));
                    }
                }
            }
        });
View Full Code Here

    }

    if (val == null) {
      return Collections.emptyList();
    }
    JSONArray arr = val.isArray();
    if (arr == null) {
      throw new RuntimeException("unrecognized payload" + val.toString());
    }
    ArrayList<MarshalledMessage> list = new ArrayList<MarshalledMessage>();
    unwrap(list, arr);
View Full Code Here

    if (val == null || val.isArray() == null) {
      throw new RuntimeException("illegal payload: must be JSONArray");
    }

    final JSONArray jsonArray = val.isArray();
    final List<Message> messageList = new ArrayList<Message>(jsonArray.size());
    for (int i = 0; i < jsonArray.size(); i++) {
       messageList.add(decodeCommandMessage(GWTJSON.wrap(jsonArray.get(i))));
    }

    return messageList;
  }
View Full Code Here

    return "json";
  }

  @Override
  public List demarshall(JSONValue o, MarshallingContext ctx) {
    JSONArray jsonArray = o.isArray();

    ArrayList<Object> list = new ArrayList<Object>();
    Marshaller<Object, Object> cachedMarshaller = null;

    for (int i = 0; i < jsonArray.size(); i++) {
      JSONValue elem = jsonArray.get(i);
      if (cachedMarshaller == null || !cachedMarshaller.handles(elem)) {
        cachedMarshaller = ctx.getMarshallerForType(ctx.determineTypeFor(null, elem));
      }

      list.add(cachedMarshaller.demarshall(elem, ctx));
View Full Code Here

            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");
View Full Code Here

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

    public static Iterable<JSONObject> getObjects(JSONObject object, String key) {
        final JSONArray array = getArray(object, key);
        return new Iterable<JSONObject>() {
            public Iterator<JSONObject> iterator() {
                return new ObjectIterator(array);
            }
        };
View Full Code Here

TOP

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

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.