Package org.json

Examples of org.json.JSONArray.optJSONObject()


      return node;
    } else {
      if (node.has("children")) {
        JSONArray children = node.optJSONArray("children");
        for (int i = 0; i < children.length(); i++) {
          JSONObject child = children.optJSONObject(i);
          JSONObject res = findWebViewNode(child);
          if (res != null) {
            return res;
          }
        }
View Full Code Here


        final JSONArray converted = json.getJSONObject(SerTokens.TOKEN_RESULT).getJSONArray(SerTokens.TOKEN_DATA);

        assertNotNull(converted);
        assertEquals(1, converted.length());

        final JSONObject vertexAsJson = converted.optJSONObject(0);
        assertNotNull(vertexAsJson);

        assertEquals(((Long) v.id()).intValue(), vertexAsJson.get(GraphSONTokens.ID)); // lossy
        assertEquals(GraphSONTokens.VERTEX, vertexAsJson.get(GraphSONTokens.TYPE));
View Full Code Here

        final JSONArray converted = json.getJSONObject(SerTokens.TOKEN_RESULT).getJSONArray(SerTokens.TOKEN_DATA);

        assertNotNull(converted);
        assertEquals(1, converted.length());

        final JSONObject edgeAsJson = converted.optJSONObject(0);
        assertNotNull(edgeAsJson);

        assertEquals(((Long) e.id()).intValue(), edgeAsJson.get(GraphSONTokens.ID))// lossy
        assertEquals(((Long) v1.id()).intValue(), edgeAsJson.get(GraphSONTokens.OUT));// lossy
        assertEquals(((Long) v2.id()).intValue(), edgeAsJson.get(GraphSONTokens.IN)); // lossy
View Full Code Here

        final JSONArray converted = json.getJSONObject(SerTokens.TOKEN_RESULT).getJSONArray(SerTokens.TOKEN_DATA);

        assertNotNull(converted);
        assertEquals(1, converted.length());

        final JSONObject vertexAsJson = converted.optJSONObject(0);
        assertNotNull(vertexAsJson);

        final JSONObject properties = vertexAsJson.optJSONObject(GraphSONTokens.PROPERTIES);
        assertNotNull(properties);
View Full Code Here

//        JSONObject obj = rows.getJSONObject(i);
        writer.write("\n");
        for(int j=0;j<headers.length();j++) {
          try {
//            writer.write("\"" + rows.optJSONObject(i).optJSONObject(headers.getString(j)).optString("value").replaceAll("\"", "\\\"") + "\"");
            writer.write(rows.optJSONObject(i).optJSONObject(headers.getString(j)).optString("value").replaceAll("\"", "\\\""));
            if(j < headers.length()-1) {
              writer.write(",");
            }
          }catch(Exception e1) {
            logger.error("Could not find key in json object");
View Full Code Here

        final JSONArray array = instance.optJSONArray(id);
        final List<StateReader> readers = new ArrayList<StateReader>();
        if (array != null) {
            final int size = array.length();
            for (int i = 0; i < size; i++) {
                readers.add(new JsonStateReader(array.optJSONObject(i)));
            }
        }
        return readers;
    }
}
View Full Code Here

    public List<StateReader> readCollection(final String id) {
        final JSONArray array = instance.optJSONArray(id);
        final List<StateReader> readers = new ArrayList<StateReader>();
        final int size = array.length();
        for (int i = 0; i < size; i++) {
            readers.add(new JsonStateReader(array.optJSONObject(i)));
        }
        return readers;
    }
}
View Full Code Here

    obj.cityCode = Result.toString(jsonObject.opt("city_code"));
    JSONArray jsonArray = jsonObject.optJSONArray("comp");
    if (jsonArray != null) {
      List<Company> companies = new ArrayList<Company>();
      for (int i = 0; i < jsonArray.length(); i++) {
        companies.add(Company.parse(jsonArray.optJSONObject(i)));
      }
      obj.companies = companies;
    }
    jsonArray = jsonObject.optJSONArray("edu");
    if (jsonArray != null) {
View Full Code Here

    }
    jsonArray = jsonObject.optJSONArray("edu");
    if (jsonArray != null) {
      List<Education> educations = new ArrayList<Education>();
      for (int i = 0; i < jsonArray.length(); i++) {
        educations.add(Education.parse(jsonArray.optJSONObject(i)));
      }
      obj.educations = educations;
    }
    obj.fansNum = Result.parseInteger(jsonObject.opt("fansnum"));
    obj.favNum = Result.parseInteger(jsonObject.opt("favnum"));
View Full Code Here

    obj.gender = Gender.parse(Result.parseInteger(jsonObject.opt("sex")));
    jsonArray = jsonObject.optJSONArray("tag");
    if (jsonArray != null) {
      List<Tag> tags = new ArrayList<Tag>();
      for (int i = 0; i < jsonArray.length(); i++) {
        tags.add(Tag.parse(jsonArray.optJSONObject(i)));
      }
      obj.tags = tags;
    }
    jsonArray = jsonObject.optJSONArray("tweetinfo");
    if (jsonArray == null) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.