Package org.json

Examples of org.json.JSONArray


    geometry.setGeometries(geometries);
    return geometry;
  }

  private Geometry createMultiLineString(Geometry geometry, JSONObject json) throws UnmarshallException {
    JSONArray lineStrings = json.getJSONArray("lineStrings");
    if (lineStrings == null) {
      throw new UnmarshallException("lineStrings are missing");
    }
    Geometry[] geometries = new Geometry[lineStrings.length()];
    for (int i = 0; i < lineStrings.length(); i++) {
      Geometry lineString = new Geometry("LineString", geometry.getSrid(), geometry.getPrecision());
      geometries[i] = createLineString(lineString, lineStrings.getJSONObject(i));
    }
    geometry.setGeometries(geometries);
    return geometry;
  }
View Full Code Here


    geometry.setGeometries(geometries);
    return geometry;
  }

  private Geometry createMultiPolygon(Geometry geometry, JSONObject json) throws UnmarshallException {
    JSONArray polygons = json.getJSONArray("polygons");
    if (polygons == null) {
      throw new UnmarshallException("polygons are missing");
    }
    Geometry[] geometries = new Geometry[polygons.length()];
    for (int i = 0; i < polygons.length(); i++) {
      Geometry polygon = new Geometry("Polygon", geometry.getSrid(), geometry.getPrecision());
      geometries[i] = createPolygon(polygon, polygons.getJSONObject(i));
    }
    geometry.setGeometries(geometries);
    return geometry;
  }
View Full Code Here

      exteriorRing.setGeometryType(Geometry.LINE_STRING);
      shell = serializeLinearRing(exteriorRing);
    }
    json.put("shell", shell);

    JSONArray holes = new JSONArray();
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 1) {
      for (int i = 1; i < geometry.getGeometries().length; i++) {
        Geometry interiorRing = geometry.getGeometries()[i];
        interiorRing.setGeometryType(Geometry.LINE_STRING);
        holes.put(serializeLinearRing(interiorRing));
      }
    }
    json.put("holes", holes);

    return json;
View Full Code Here

  private JSONObject serializeMultiPoint(Geometry geometry) {
    JSONObject json = new JSONObject();
    putBasics(json, geometry);

    JSONArray points = null;
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 0) {
      points = new JSONArray();
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        points.put(serializePoint(geometry.getGeometries()[i]));
      }
    }
    json.put("points", points);
    return json;
  }
View Full Code Here

  }

  private JSONObject serializeMultiLineString(Geometry geometry) {
    JSONObject json = new JSONObject();

    JSONArray lineStrings = null;
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 0) {
      lineStrings = new JSONArray();
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        lineStrings.put(serializeLineString(geometry.getGeometries()[i]));
      }
    }
    json.put("lineStrings", lineStrings);
    putBasics(json, geometry);
    return json;
View Full Code Here

  private JSONObject serializeMultiPolygon(Geometry geometry) {
    JSONObject json = new JSONObject();
    putBasics(json, geometry);

    JSONArray polygons = null;
    if (geometry.getGeometries() != null && geometry.getGeometries().length > 0) {
      polygons = new JSONArray();
      for (int i = 0; i < geometry.getGeometries().length; i++) {
        polygons.put(serializePolygon(geometry.getGeometries()[i]));
      }
    }
    json.put("polygons", polygons);
    return json;
  }
View Full Code Here

    json.put(ATTRIBUTE_PRECISION, geometry.getPrecision());
  }

  private void putCoordinates(JSONObject json, Geometry geometry) {
    // Put a coordinate array into the JSON object:
    JSONArray coordinates = new JSONArray();
    for (int i = 0; i < geometry.getCoordinates().length; i++) {
      coordinates.put(geometry.getCoordinates()[i].getX());
      coordinates.put(geometry.getCoordinates()[i].getY());
    }
    json.put(ATTRIBUTE_COORDINATES, coordinates);
  }
View Full Code Here

    } else if (o instanceof Number) {
      write(JSONObject.numberToString((Number) o));
    } else if (o instanceof Writable) {
      ((Writable) o).write(this);
    } else if (o instanceof JSONArray) {
      JSONArray array = (JSONArray) o;
      write("[");
      for (int i = 0; i < array.length(); i++) {
        if (i != 0) {
          write(",");
        }
        writeObject(array.get(i));
      }
      write("]");
    } else if (o instanceof JSONObject) {
      write((JSONObject) o);
    } else {
View Full Code Here

    String tag= proxyMap.get(proxyObj);
    String methodTag= tag==null ? "" : tag + ".";
    methodTag+=methodName;
    message.put("method", methodTag);

    JSONArray params= new JSONArray();
    if (args!=null) {
      for(Object arg: args) {
        SerializerState state= new SerializerState();
        params.put(message2Object.marshall(state, arg));
      }
    }
    message.put("params", params);
    message.put("id", 1);
    JSONObject responseMessage= session.sendAndReceive(message);
View Full Code Here

    public void put(EntryParam param, String[] array)
    {
        checkType(param.toString());
        try
        {
            m_json.put(param.toString(), new JSONArray(Arrays.asList(array)));
        }
        catch (JSONException e)
        {
            throw new IllegalArgumentException("could not add param " + param + ":"
                + Arrays.toString(array), e);
View Full Code Here

TOP

Related Classes of org.json.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.