Package org.json

Examples of org.json.JSONObject.names()


                return failureResultForStatusCode(responseStatus);

            JSONObject result = new JSONObject(get.getResponseBodyAsString());

            ResourceProxy resource = new ResourceProxy(path);
            JSONArray names = result.names();
            for (int i = 0; i < names.length(); i++) {
                String name = names.getString(i);
                Object object = result.get(name);
                if (object instanceof String) {
                    resource.addProperty(name, object);
View Full Code Here


            final Set<String> keyNames = Repositories.getKeyNames(Article.ARTICLE);

            for (int i = 0; i < articles.length(); i++) {
                final JSONObject article = articles.getJSONObject(i);

                final JSONArray names = article.names();
                final Set<String> nameSet = CollectionUtils.<String>jsonArrayToSet(names);

                if (nameSet.removeAll(keyNames)) {
                    for (final String unusedName : nameSet) {
                        article.remove(unusedName);
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

            final Set<String> keyNames = Repositories.getKeyNames(Article.ARTICLE);
            for (int i = 0; i < articles.length(); i++) {
                final JSONObject article = articles.getJSONObject(i);

                final JSONArray names = article.names();
                final Set<String> nameSet = CollectionUtils.<String>jsonArrayToSet(names);

                if (nameSet.removeAll(keyNames)) {
                    for (final String unusedName : nameSet) {
                        article.remove(unusedName);
View Full Code Here

            Asset<String> themeAsset = repository.loadAssetFromPath(profile.getRepositoryGlobalDir( uuid ) + "/" + THEME_NAME+THEME_EXT);

            JSONObject themesObject =  new JSONObject(themeAsset.getAssetContent());
            JSONObject themes = (JSONObject) themesObject.get("themes");
            for (int i = 0; i < themes.names().length(); i++) {
                themesStr += themes.names().getString(i) + ",";
            }
            if(themesStr.endsWith(",")) {
                themesStr = themesStr.substring(0, themesStr.length() - 1);
            }
View Full Code Here

            Asset<String> themeAsset = repository.loadAssetFromPath(profile.getRepositoryGlobalDir( uuid ) + "/" + THEME_NAME+THEME_EXT);

            JSONObject themesObject =  new JSONObject(themeAsset.getAssetContent());
            JSONObject themes = (JSONObject) themesObject.get("themes");
            for (int i = 0; i < themes.names().length(); i++) {
                themesStr += themes.names().getString(i) + ",";
            }
            if(themesStr.endsWith(",")) {
                themesStr = themesStr.substring(0, themesStr.length() - 1);
            }
View Full Code Here

    private void loadCollections() throws IOException {
        try {
            final String json = _dbfile.getText();
            final JSONObject data = new JSONObject(json);
            final JSONArray collNames = data.names();
            if (null != collNames) {
                final int lenght = collNames.length();
                for (int i = 0; i < lenght; i++) {
                    final String collName = collNames.getString(i);
                    final Object item = data.get(collName);
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 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

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.