Package org.json

Examples of org.json.JSONObject.names()


    }

    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


     */
    public boolean isSettingUserPref() {
        try {
            if (metadata_ != null) {
                JSONObject userPrefs = metadata_.getJSONObject(METADATA_USERPREFS);
                JSONArray names = userPrefs.names();
                int count = names.length();
                if (count > 0) {
                    for (int i = 0; i < count; i++) {
                        JSONObject o = (JSONObject) userPrefs.get(names.get(i).toString());
                        String prefType = o.optString(METADATA_USERPREFS_TYPE);
View Full Code Here

            {
                Map<String, EntityReference> references = new LinkedHashMap<>();
                try
                {
                    JSONObject jsonValues = namedAssocs.getJSONObject( namedAssociationType.qualifiedName().name() );
                    JSONArray names = jsonValues.names();
                    if( names != null )
                    {
                        for( int idx = 0; idx < names.length(); idx++ )
                        {
                            String name = names.getString( idx );
View Full Code Here

            {
                Map<String, EntityReference> references = new LinkedHashMap<>();
                try
                {
                    JSONObject jsonValues = namedAssocs.getJSONObject( namedAssociationType.qualifiedName().name() );
                    JSONArray names = jsonValues.names();
                    if( names != null )
                    {
                        for( int idx = 0; idx < names.length(); idx++ )
                        {
                            String name = names.getString( idx );
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());
      String key;
      for (Iterator keys = expectedObject.keys(); keys.hasNext();
          assertJsonEquals(expectedObject.get(key), actualObject.get(key))) {
        key = (String) keys.next();
        assertTrue(actualObject.has(key));
View Full Code Here

      for (int i = 0; i < stepsA.length(); i++) {
        JSONObject stepO = stepsA.getJSONObject(i);
        Script.Step step = new Script.Step(getStepTypeOfName(stepO.getString("type")));
        step.negated = stepO.optBoolean("negated", false);
        script.steps.add(step);
        JSONArray keysA = stepO.names();
        for (int j = 0; j < keysA.length(); j++) {
          String key = keysA.getString(j);
          if (key.equals("type") || key.equals("negated")) { continue; }
          if (stepO.optJSONObject(key) != null) {
            step.locatorParams.put(key, new Locator(
View Full Code Here

     
      JSONObject module = (JSONObject) libraryIndex.get("!define");
      if (verbose) debug("(("+module.length()+")):");
     
      //DONE add moduleDesc as list of higher level objects
      String moduleDesc = formatedName(moduleName)+module.names();
      Entry moduleEntry = new Entry(moduleObj,EntryType.module,moduleName,moduleName,moduleDesc,null);
      model.addEntry(moduleEntry)
     
      if (verbose) debug("\n    Model size="+model.entries.size());
     
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

    String jsCode = builder.build().toJsString();
    String startCode = BASE_CODE + "window['___cfg']=";
    assertTrue(jsCode.startsWith(startCode));
    String json = jsCode.substring(startCode.length(), jsCode.length() - ";\n".length());
    JSONObject configObj = new JSONObject(json);
    assertEquals(1, configObj.names().length());
    assertEquals("reqval1:MODIFIED", configObj.getString("reqfeature1"));
  }
}
View Full Code Here

      {
        JSONObject values = jsonValues.optJSONObject(symbol);
        if (values == null)
          throw new JSONException("Variable "+ symbol + " does not have value.");

        JSONArray keysList = values.names();
        int keySize = keysList == null ? 0 : keysList.length();
       
        // denote if the map is represented in a way of combination of key jsonarray and value jsonarray;
        boolean isKeyValue = isKeyValueArrayMethod(values);
        JSONArray keysArrayList = null, valuesArrayList = 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.