@SuppressWarnings( "unchecked" ) public String getDatabases() { JSONArray list = new JSONArray(); for ( int i = 0; i < repositoriesMeta.nrDatabases(); i++ ) { JSONObject databaseJSON = new JSONObject(); databaseJSON.put( "name", repositoriesMeta.getDatabase( i ).getName() ); list.add( databaseJSON ); } return list.toString(); }
@SuppressWarnings( "unchecked" ) public String getPlugins() { List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class ); JSONArray list = new JSONArray(); for ( PluginInterface pluginInterface : plugins ) { if ( !pluginInterface.getIds()[0].equals( "PentahoEnterpriseRepository" ) ) { JSONObject repoJSON = new JSONObject(); repoJSON.put( "id", pluginInterface.getIds()[ 0 ] ); repoJSON.put( "name", pluginInterface.getName() ); repoJSON.put( "description", pluginInterface.getDescription() ); list.add( repoJSON ); } } return list.toString(); }
private static String getJsonString(Collection<String> strings) { JSONArray array = new JSONArray(); if (strings != null && !strings.isEmpty()) { array.addAll(strings); } return array.toString(); } }
private static Put putRequestFromIntel(JSONObject intel) { Put tempPut = new Put(Bytes.toBytes((String) intel.get("indicator"))); JSONArray intelArray = (JSONArray) intel.get("data"); tempPut.add(Bytes.toBytes("source"), Bytes.toBytes((String) intel.get("source")), Bytes.toBytes(intelArray.toString())); return tempPut; } /*
@Override public String toString() { return toJSON(new DecimalFormat(Histogram.DEFAULT_FORMAT_STRING)).toString(); }
public static String encodeToJSON(Collection list) { return encodeToJSONArray(list).toString(); }
public static String toJson(Arr arr) { return toJsonSimple(arr).toString(); }
@GET @Path("list") @Produces("application/javascript") public String getUserList() { String result = ""; try { result = UserStore.list().toString(); } catch (IllegalAccessException e) { log.error(ExceptionUtil.getStackTrace(e)); throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND) .entity("User does not exist.").build()); } return result; } }
public String convertObjectsToViewList(JSONObject[] objArray) { JSONArray jsonArr = new JSONArray(); JSONObject permission = new JSONObject(); JSONObject user = new JSONObject(); try { permission.put("read", 1); permission.put("modify", 1); user.put("all", permission); } catch (Exception e) { System.err.println("JSON Exception: " + e.getMessage()); } for (int i = 0; i < objArray.length; i++) { try { JSONObject jsonObj = new JSONObject(); jsonObj.put("key", objArray[i].get("key")); jsonObj.put("description", objArray[i].get("description")); jsonObj.put("owner", ""); jsonObj.put("permission", user); jsonArr.add(jsonObj); } catch (Exception e) { System.err.println("JSON Exception: " + e.getMessage()); } } return jsonArr.toString(); }
public static void toString(StringBuilder sb, String key,Object value){ sb.append("\""); escape(sb,key); sb.append("\":"); if(value==null){ sb.append("null"); return; } if(value instanceof String){ sb.append("\""); escape(sb,(String)value); sb.append("\""); }else if ( value instanceof JSONObject ){ ((JSONObject)value).toString( sb ); }else if ( value instanceof JSONArray ){ ((JSONArray)value).toString( sb ); }else{ sb.append(String.valueOf( value )); } }
@Override @PublicAtsApi public String toString() { if (jsonObject != null) { return jsonObject.toString(); } else if (jsonArray != null) { return jsonArray.toString(); } else if (javaObject != null) { return javaObject.toString(); } else { // this is legal, we are pointing to a NULL value somewhere inside the JSON text return null; } }
public void toString( StringBuilder sb ){ sb.append( "[" ); Iterator<Object> iter=iterator(); boolean first = true; while(iter.hasNext()){ if ( first ){ first = false; }else{ sb.append( "," ); } Object value=iter.next(); if(value instanceof String){ sb.append( "\"" ); JSONObject.escape(sb, (String)value); sb.append( "\""); }else if ( value instanceof JSONObject ){ ((JSONObject)value).toString( sb ); }else if ( value instanceof JSONArray ){ ((JSONArray)value).toString( sb ); }else{ sb.append(String.valueOf(value)); } } sb.append( "]" ); } }
@SuppressWarnings("unchecked") public String candidateType(String text, NEDAlgo_HITS agdistis) throws IOException { JSONArray arr = new org.json.simple.JSONArray(); Document d = textToDocument(text); Map<NamedEntityInText, List<CandidatesScore>> candidatesPerNE = new HashMap<>(); agdistis.run(d, candidatesPerNE); for (NamedEntityInText namedEntity : candidatesPerNE.keySet()) { List<CandidatesScore> candidates = candidatesPerNE.get(namedEntity); JSONObject obj = new JSONObject(); obj.put("namedEntity", namedEntity.getLabel()); obj.put("Candidates", candidates.toString()); arr.add(obj); } log.info("\t" + arr.toString()); log.info("Finished Request"); agdistis.close(); return arr.toString(); } }
plain = jsonObject.toString(); } else if (jsonArray != null) { plain = jsonArray.toString(); } else { plain = javaObject.toString();
public String getContents() { JSONArray out = new JSONArray(); for (ItemStackEntry entry : contents) { out.add(entry.serialize()); } return out.toString(); }
/** * This returns the json string containing the role permissions for a given API * * @param connection - DB connection * @param apiId - apiId of the API * @return permission string * @throws SQLException - if error occurred while getting permissionMap of API from DB */ private String getPermissionsStringForApi(Connection connection, String apiId) throws SQLException { JSONArray permissionArray = new JSONArray(); Map<String, Integer> permissionMap = getPermissionMapForApi(connection, apiId); for (Map.Entry<String, Integer> entry : permissionMap.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put(APIMgtConstants.Permission.GROUP_ID, entry.getKey()); jsonObject.put(APIMgtConstants.Permission.PERMISSION, APIUtils.constructApiPermissionsListForValue(entry.getValue())); permissionArray.add(jsonObject); } if (!permissionArray.isEmpty()) { return permissionArray.toString(); } else { return ""; } }
/** * This returns the json string containing the role permissions for a given API * * @param connection - DB connection * @param apiId - apiId of the API * @return permission string * @throws SQLException - if error occurred while getting permissionMap of API from DB */ private String getPermissionsStringForApi(Connection connection, String apiId) throws SQLException { JSONArray permissionArray = new JSONArray(); Map<String, Integer> permissionMap = getPermissionMapForApi(connection, apiId); for (Map.Entry<String, Integer> entry : permissionMap.entrySet()) { JSONObject jsonObject = new JSONObject(); jsonObject.put(APIMgtConstants.Permission.GROUP_ID, entry.getKey()); jsonObject.put(APIMgtConstants.Permission.PERMISSION, APIUtils.constructApiPermissionsListForValue(entry.getValue())); permissionArray.add(jsonObject); } if (!permissionArray.isEmpty()) { return permissionArray.toString(); } else { return ""; } }
sb.append("\n page: " + location); sb.append("\n callerName: " + callerName); sb.append("\n messageArgs: " + messageArgs.toString()); logger.error(sb.toString());
@SuppressWarnings("unchecked") public String standardAG(String text, NEDAlgo_HITS agdistis) throws IOException { JSONArray arr = new org.json.simple.JSONArray(); Document d = textToDocument(text); agdistis.run(d, null); for (NamedEntityInText namedEntity : d.getNamedEntitiesInText()) { if(!namedEntity.getNamedEntityUri().contains("http")){ namedEntity.setNamedEntity("http://aksw.org/notInWiki/" + namedEntity.getSingleWordLabel()); } JSONObject obj = new JSONObject(); obj.put("namedEntity", namedEntity.getLabel()); obj.put("start", namedEntity.getStartPos()); obj.put("offset", namedEntity.getLength()); obj.put("disambiguatedURL", namedEntity.getNamedEntityUri()); arr.add(obj); } log.info("\t" + arr.toString()); log.info("Finished Request"); agdistis.close(); return arr.toString(); }