Package com.google.gwt.json.client

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


  public void buildLevel(){
    JSONObject levelCreations=jsonContext.get("creations").isObject();
    JSONValue unknownCreation;
    LevelBuilder builder;
   
    JSONArray creationArray;
   
    int i;
   
    for(String key:levelCreations.keySet()){
      unknownCreation=levelCreations.get(key);
      builder=BUILDER_MAP.get(key);
      if(unknownCreation.isArray()!=null){
        creationArray=unknownCreation.isArray();
       
        for(i=0;i<creationArray.size();i++){
          builder.build(creationArray.get(i).isObject());
        }
      }else{
        builder.build(unknownCreation.isObject());
      }
    }
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

                + markerJSON.length()
                + " bytes of marker response got in "
                + (System.currentTimeMillis() - markerRequestSentAt)
                + "ms");

            JSONArray array = null;
            try {
              long start = System.currentTimeMillis();
              JSONValue json = JSONParser.parse(markerJSON);
              array = json.isArray();
              log(1,
View Full Code Here

    return jsobj;
  }

  @SuppressWarnings("unchecked")
  protected static JSONArray encodeList(List<Object> data) {
    JSONArray jsona = new JSONArray();
    for (int i = 0; i < data.size(); i++) {
      Object val = data.get(i);
      if (val instanceof ModelData) {
        jsona.set(i, encodeMap(((ModelData) val).getProperties()));
      } else if (val instanceof Map) {
        jsona.set(i, encodeMap((Map<String, Object>) val));
      } else if (val instanceof List) {
        jsona.set(i, encodeList((List<Object>) val));
      } else if (val instanceof String) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Number) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Boolean) {
        jsona.set(i, JSONBoolean.getInstance((Boolean) val));
      } else if (val == null) {
        jsona.set(i, JSONNull.getInstance());
      } else if (val instanceof Date) {
        jsona.set(i, new JSONString(encodeValue(val)));
      }
    }
    return jsona;
  }
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 (data instanceof JavaScriptObject) {
      jsonRoot = new JSONObject((JavaScriptObject) data);
    } else {
      jsonRoot = (JSONObject) JSONParser.parse((String) data);
    }
    JSONArray root = (JSONArray) jsonRoot.get(modelType.getRoot());
    int size = root.size();
    ArrayList<ModelData> models = new ArrayList<ModelData>();
    for (int i = 0; i < size; i++) {
      JSONObject obj = (JSONObject) root.get(i);
      ModelData model = newModelInstance();
      for (int j = 0; j < modelType.getFieldCount(); j++) {
        DataField field = modelType.getField(j);
        String name = field.getName();
        Class type = field.getType();
View Full Code Here

      @Override
      public void onSuccess(String result) {
        try {
          String textHTML = "";
          JSONValue value = JSONParser.parseLenient(result);
          JSONArray devicesArray = value.isArray();

          if (devicesArray != null) {

            textHTML = "Result:";

            for (int i = 0; i < devicesArray.size(); i++) {
              JSONObject deviceObj = devicesArray.get(i)
                  .isObject();
              textHTML = textHTML + "<br/>"
                  + deviceObj.get("name");
            }
View Full Code Here

      @Override
      public void onSuccess(String result) {
        try {
          String textHTML = "";
          JSONValue value = JSONParser.parseLenient(result);
          JSONArray devicesArray = value.isArray();

          if (devicesArray != null) {
            textHTML = "Result:";
            for (int i = 0; i < devicesArray.size(); i++) {
              JSONObject deviceObj = devicesArray.get(i).isObject();
              textHTML = textHTML + "<br/>"
                  + deviceObj.get("name");
            }
            text.setHTML(textHTML);
          }
View Full Code Here

  @Override
  public List<GadgetInfo> parseGadgetInfoJson(String json) {
    List<GadgetInfo> gadgetList = new ArrayList<GadgetInfo>();
    JSONValue value = JSONParser.parseStrict(json);
    JSONArray array = value.isArray();
    if (array != null) {
      for (int i = 0; i < array.size(); i++) {
        JSONValue item = array.get(i);
        GadgetInfo info = parseGadgetInfo(item);
        if (info != null) {
          gadgetList.add(info);
        }
      }
View Full Code Here

      return;
    }

    JSONObject request = new JSONObject();
    JSONObject requestContext = new JSONObject();
    JSONArray gadgets = new JSONArray();
    JSONObject gadget = new JSONObject();
    try {
      gadget.put("url", new JSONString(gadgetSpecUrl));
      gadgets.set(0, gadget);
      requestContext.put("container", new JSONString("wave"));
      request.put("context", requestContext);
      request.put("gadgets", gadgets);
      RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, GADGET_METADATA_PATH);
      builder.sendRequest(request.toString(), new RequestCallback() {
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.