Package org.json

Examples of org.json.JSONObject.names()


          long candidateScore = candidateObj.getLong("score");
          JSONObject candidateAttributes = candidateObj.getJSONObject("attributes");
          double candidateX = candidateLocation.getDouble("x");
          double candidateY = candidateLocation.getDouble("y");
          StringAttributeMap attributes = new StringAttributeMap();
          JSONArray names = candidateAttributes.names();
          for (int n = 0; n < (names != null ? names.length() : 0); n++) {
            String name = names.getString(n);
            String value = candidateAttributes.getString(name);
            attributes.add(new StringAttribute(name, value));
          }
View Full Code Here


      JSONObject actualObject = (JSONObject) actual;
      if (expectedObject.length() == 0) {
        assertEquals(expectedObject.length(), actualObject.length());
        return;
      }
      assertEquals(expectedObject.names().length(), actualObject.names().length());
     
      for (String key : JSONObject.getNames(expectedObject)) {
        assertTrue("missing key " + key, actualObject.has(key));
        assertJsonEquals(expectedObject.get(key), actualObject.get(key));
      }
View Full Code Here

                        } else {

                            JSONObject j = new JSONObject(line);

                            String topLevelParent;
                            topLevelParent = (String) j.names().get(0);
                            Iterator it = j.getJSONObject(topLevelParent).keys();

                            while (it.hasNext()) {
                                String k = (String) it.next();
                                Double value = (Double) j.getJSONObject(topLevelParent).getDouble(k);
View Full Code Here

    }

    private Node doBuild(String json, String path) throws Exception {
        try {
            JSONObject jsonObject = new JSONObject(json);
            JSONArray names = jsonObject.names();
            if (names.length() != 1) {
                throw new IllegalArgumentException("JSON must contain exactly 1 root node");
            }

            String name = names.getString(0);
View Full Code Here

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonRow = (JSONObject) jsonArray.get(i);

                // create row and populate fields
                FormRow row = new FormRow();
                JSONArray fields = jsonRow.names();
                if (fields != null && fields.length() > 0) {
                    for (int k = 0; k < fields.length(); k++) {
                        String fieldName = fields.getString(k);
                        String value = jsonRow.getString(fieldName);
                        row.setProperty(fieldName, value);
View Full Code Here

              emailVerified = jsonResponse.getBoolean("emailVerified");
              emailVerifiedChanged = true;
            } catch (Exception e) {
             
            } 
            addOtherNames(getOtherFieldNames(jsonResponse.names()), jsonResponse);
          }catch (JSONException e){
            throw new ParseException(
                ParseException.INVALID_JSON,
                "Although Parse reports object successfully saved, the response was invalid.",
                e);
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.