protected JSON json(MockHttpServletResponse response) throws UnsupportedEncodingException { String content = response.getContentAsString(); return JSONSerializer.toJSON(content); }
protected JSON json(MockHttpServletResponse response) throws UnsupportedEncodingException { String content = response.getContentAsString(); return JSONSerializer.toJSON(content); }
public void setApplicationsWithVersion(List<ApplicationWithVersion> applicationsWithVersion) { JSON json = JSONSerializer.toJSON(applicationsWithVersion); this.applicationsWithVersion = json.toString(); applicationsWithVersionList = null; }
private static JSONObject parseSlaveAttributes(String slaveAttributes) { if (StringUtils.isNotBlank(slaveAttributes)) { try { return (JSONObject) JSONSerializer.toJSON(slaveAttributes); } catch (JSONException e) { LOGGER.warning("Ignoring Mesos slave attributes JSON due to parsing error : " + slaveAttributes); } } return null; }
public static Set<SecurityIndexType> jsonToIndexesTypes(String json) { List<String> securityIndexesTypes = (List<String>) JSONSerializer.toJava(JSONSerializer.toJSON(json)); Set<SecurityIndexType> securityIndexes = securityIndexesTypes.stream().map(SecurityIndexType::valueOf).collect(Collectors.toSet()); return securityIndexes; }
public static Set<Country> jsonToCountries(String json) { List<String> countryNames = (List<String>) JSONSerializer.toJava(JSONSerializer.toJSON(json)); Set<Country> countries = countryNames.stream().map(Country::valueOf).collect(Collectors.toSet()); return countries; }
@Override public void visit(String line) throws GerritQueryException { JSONObject json = (JSONObject)JSONSerializer.toJSON(line.trim()); if (json.has("type") && "error".equalsIgnoreCase(json.getString("type"))) { throw new GerritQueryException(json.getString("message")); } list.add(json); } });
@Override public void visit(String line) throws GerritQueryException { JSONObject json = (JSONObject)JSONSerializer.toJSON(line.trim()); if (json.has("type") && "error".equalsIgnoreCase(json.getString("type"))) { throw new GerritQueryException(json.getString("message")); } list.add(json); } });
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); resp.getWriter().write(JSONSerializer.toJSON(ServerSettingsManager.getSettings().getDicomServicesSettings().getMoveDestinations()).toString()); }
public static String violationToJson(Violation violation) { Map<String, String> limitViolation = new HashMap<String, String>(); limitViolation.put("Subject", violation.getSubject()); limitViolation.put("LimitType", violation.getLimitType().name()); limitViolation.put("Limit", Float.toString(violation.getLimit())); limitViolation.put("Value", Float.toString(violation.getValue())); return JSONSerializer.toJSON(limitViolation).toString(); }
protected Collection<String> jsonArrayToCollection(ConversionMap<String, Object> map, String key) { JSONArray json = (JSONArray) JSONSerializer.toJSON(map.get(key)); Collection<String> zzz = (Collection<String>) JSONSerializer.toJava(json); return zzz; }
public String requestQualityGateStatus(String analysisId) { String url = serverUrl + API_PROJECT_STATUS_WITH_ANALYSISID + encode(analysisId); String text = client.getHttp(url, token); try { JSONObject json = (JSONObject) JSONSerializer.toJSON(text); JSONObject projectStatus = json.getJSONObject("projectStatus"); return projectStatus.getString(STATUS_ATTR); } catch (JSONException e) { throw new IllegalStateException("Unable to parse response from " + url + ":\n" + text, e); } }
public void write(Object object, OutputStream out) throws IOException { JsonConfig cfg = new JsonConfig(); cfg.setIgnoreTransientFields(true); cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); JSON json = JSONSerializer.toJSON(object, cfg); Writer writer = new PrintWriter(out); json.write(writer); writer.flush(); } }
@Deprecated private String ConvertToXML(String jsonData) { XMLSerializer serializer = new XMLSerializer(); JSON json = JSONSerializer.toJSON(jsonData); serializer.setRootName("xmlOutput"); serializer.setTypeHintsEnabled(false); return serializer.write(json); }
@Deprecated private String ConvertToXML(String jsonData) { XMLSerializer serializer = new XMLSerializer(); JSON json = JSONSerializer.toJSON(jsonData); serializer.setRootName("xmlOutput"); serializer.setTypeHintsEnabled(false); String xml = serializer.write(json); return xml; }
protected Collection<LDAPConfiguration> mapToLDAPS(ConversionMap<String, Object> map, String key) { JSONObject json = new JSONObject(); JSON j = JSONSerializer.toJSON(map.get(key)); json.put("ldap", j); return getLdapConfigurationUtil().fromJSON(j); }
@Test public void testJSON() throws Exception { Map map = new HashMap(); map.put("name", "bomb"); map.put("price", 12.99); ByteArrayOutputStream bout = new ByteArrayOutputStream(); new MapJSONPPIO().encode(map, bout); JSON json = JSONSerializer.toJSON(new String(bout.toByteArray())); JSONObject obj = (JSONObject) json; assertEquals("bomb", obj.getString("name")); assertEquals(12.99, obj.getDouble("price"), 0.1); }
private void convertToXML() { XMLSerializer serializer = new XMLSerializer(); JSON json = JSONSerializer.toJSON(this.getJsonInput()); serializer.setRootName("xmlOutput"); serializer.setTypeHintsEnabled(false); setXmlOutput(serializer.write(json)); }
private void convertToXML() { XMLSerializer serializer = new XMLSerializer(); JSON json = JSONSerializer.toJSON(this.getJsonInput()); serializer.setRootName("xmlOutput"); serializer.setTypeHintsEnabled(false); setXmlOutput(serializer.write(json)); }
/** * Test ProjectListRefreshInterval zero value after upgrade from gerrit-trigger version 2.13.0 to 2.14.0. */ @Test public void testProjectListRefreshIntervalZeroValue() { String formString = "{\"projectListRefreshInterval\":\"0\"}"; JSONObject form = (JSONObject)JSONSerializer.toJSON(formString); Config config = new Config(form); assertEquals(Config.DEFAULT_PROJECT_LIST_REFRESH_INTERVAL, config.getProjectListRefreshInterval()); }