net.sf.json.JSONSerializer.toJSON()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(356)

本文整理了Java中net.sf.json.JSONSerializer.toJSON()方法的一些代码示例,展示了JSONSerializer.toJSON()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONSerializer.toJSON()方法的具体详情如下:
包路径:net.sf.json.JSONSerializer
类名称:JSONSerializer
方法名:toJSON

JSONSerializer.toJSON介绍

暂无

代码示例

代码示例来源:origin: geoserver/geoserver

  1. protected JSON json(MockHttpServletResponse response) throws UnsupportedEncodingException {
  2. String content = response.getContentAsString();
  3. return JSONSerializer.toJSON(content);
  4. }

代码示例来源:origin: geoserver/geoserver

  1. protected JSON json(MockHttpServletResponse response) throws UnsupportedEncodingException {
  2. String content = response.getContentAsString();
  3. return JSONSerializer.toJSON(content);
  4. }

代码示例来源:origin: liimaorg/liima

  1. public void setApplicationsWithVersion(List<ApplicationWithVersion> applicationsWithVersion) {
  2. JSON json = JSONSerializer.toJSON(applicationsWithVersion);
  3. this.applicationsWithVersion = json.toString();
  4. applicationsWithVersionList = null;
  5. }

代码示例来源:origin: jenkinsci/mesos-plugin

  1. private static JSONObject parseSlaveAttributes(String slaveAttributes) {
  2. if (StringUtils.isNotBlank(slaveAttributes)) {
  3. try {
  4. return (JSONObject) JSONSerializer.toJSON(slaveAttributes);
  5. } catch (JSONException e) {
  6. LOGGER.warning("Ignoring Mesos slave attributes JSON due to parsing error : " + slaveAttributes);
  7. }
  8. }
  9. return null;
  10. }

代码示例来源:origin: itesla/ipst

  1. public static Set<SecurityIndexType> jsonToIndexesTypes(String json) {
  2. List<String> securityIndexesTypes = (List<String>) JSONSerializer.toJava(JSONSerializer.toJSON(json));
  3. Set<SecurityIndexType> securityIndexes = securityIndexesTypes.stream().map(SecurityIndexType::valueOf).collect(Collectors.toSet());
  4. return securityIndexes;
  5. }

代码示例来源:origin: itesla/ipst

  1. public static Set<Country> jsonToCountries(String json) {
  2. List<String> countryNames = (List<String>) JSONSerializer.toJava(JSONSerializer.toJSON(json));
  3. Set<Country> countries = countryNames.stream().map(Country::valueOf).collect(Collectors.toSet());
  4. return countries;
  5. }

代码示例来源:origin: com.sonyericsson.hudson.plugins.gerrit/gerrit-events

  1. @Override
  2. public void visit(String line) throws GerritQueryException {
  3. JSONObject json = (JSONObject)JSONSerializer.toJSON(line.trim());
  4. if (json.has("type") && "error".equalsIgnoreCase(json.getString("type"))) {
  5. throw new GerritQueryException(json.getString("message"));
  6. }
  7. list.add(json);
  8. }
  9. });

代码示例来源:origin: org.hudsonci.plugins/gerrit-events

  1. @Override
  2. public void visit(String line) throws GerritQueryException {
  3. JSONObject json = (JSONObject)JSONSerializer.toJSON(line.trim());
  4. if (json.has("type") && "error".equalsIgnoreCase(json.getString("type"))) {
  5. throw new GerritQueryException(json.getString("message"));
  6. }
  7. list.add(json);
  8. }
  9. });

代码示例来源:origin: bioinformatics-ua/dicoogle

  1. @Override
  2. protected void doGet(HttpServletRequest req, HttpServletResponse resp)
  3. throws ServletException, IOException {
  4. resp.setContentType("application/json");
  5. resp.getWriter().write(JSONSerializer.toJSON(ServerSettingsManager.getSettings().getDicomServicesSettings().getMoveDestinations()).toString());
  6. }

代码示例来源:origin: itesla/ipst

  1. public static String violationToJson(Violation violation) {
  2. Map<String, String> limitViolation = new HashMap<String, String>();
  3. limitViolation.put("Subject", violation.getSubject());
  4. limitViolation.put("LimitType", violation.getLimitType().name());
  5. limitViolation.put("Limit", Float.toString(violation.getLimit()));
  6. limitViolation.put("Value", Float.toString(violation.getValue()));
  7. return JSONSerializer.toJSON(limitViolation).toString();
  8. }

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

  1. protected Collection<String> jsonArrayToCollection(ConversionMap<String, Object> map, String key) {
  2. JSONArray json = (JSONArray) JSONSerializer.toJSON(map.get(key));
  3. Collection<String> zzz = (Collection<String>) JSONSerializer.toJava(json);
  4. return zzz;
  5. }

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

  1. public String requestQualityGateStatus(String analysisId) {
  2. String url = serverUrl + API_PROJECT_STATUS_WITH_ANALYSISID + encode(analysisId);
  3. String text = client.getHttp(url, token);
  4. try {
  5. JSONObject json = (JSONObject) JSONSerializer.toJSON(text);
  6. JSONObject projectStatus = json.getJSONObject("projectStatus");
  7. return projectStatus.getString(STATUS_ATTR);
  8. } catch (JSONException e) {
  9. throw new IllegalStateException("Unable to parse response from " + url + ":\n" + text, e);
  10. }
  11. }

代码示例来源:origin: miltonio/milton2

  1. public void write(Object object, OutputStream out) throws IOException {
  2. JsonConfig cfg = new JsonConfig();
  3. cfg.setIgnoreTransientFields(true);
  4. cfg.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
  5. JSON json = JSONSerializer.toJSON(object, cfg);
  6. Writer writer = new PrintWriter(out);
  7. json.write(writer);
  8. writer.flush();
  9. }
  10. }

代码示例来源:origin: undera/jmeter-plugins

  1. @Deprecated
  2. private String ConvertToXML(String jsonData) {
  3. XMLSerializer serializer = new XMLSerializer();
  4. JSON json = JSONSerializer.toJSON(jsonData);
  5. serializer.setRootName("xmlOutput");
  6. serializer.setTypeHintsEnabled(false);
  7. return serializer.write(json);
  8. }

代码示例来源:origin: kg.apc/jmeter-plugins-extras-libs

  1. @Deprecated
  2. private String ConvertToXML(String jsonData) {
  3. XMLSerializer serializer = new XMLSerializer();
  4. JSON json = JSONSerializer.toJSON(jsonData);
  5. serializer.setRootName("xmlOutput");
  6. serializer.setTypeHintsEnabled(false);
  7. String xml = serializer.write(json);
  8. return xml;
  9. }

代码示例来源:origin: edu.uiuc.ncsa.myproxy/oa4mp-server-loader-oauth2

  1. protected Collection<LDAPConfiguration> mapToLDAPS(ConversionMap<String, Object> map, String key) {
  2. JSONObject json = new JSONObject();
  3. JSON j = JSONSerializer.toJSON(map.get(key));
  4. json.put("ldap", j);
  5. return getLdapConfigurationUtil().fromJSON(j);
  6. }

代码示例来源:origin: org.geoserver.script/gs-script-core

  1. @Test
  2. public void testJSON() throws Exception {
  3. Map map = new HashMap();
  4. map.put("name", "bomb");
  5. map.put("price", 12.99);
  6. ByteArrayOutputStream bout = new ByteArrayOutputStream();
  7. new MapJSONPPIO().encode(map, bout);
  8. JSON json = JSONSerializer.toJSON(new String(bout.toByteArray()));
  9. JSONObject obj = (JSONObject) json;
  10. assertEquals("bomb", obj.getString("name"));
  11. assertEquals(12.99, obj.getDouble("price"), 0.1);
  12. }

代码示例来源:origin: undera/jmeter-plugins

  1. private void convertToXML() {
  2. XMLSerializer serializer = new XMLSerializer();
  3. JSON json = JSONSerializer.toJSON(this.getJsonInput());
  4. serializer.setRootName("xmlOutput");
  5. serializer.setTypeHintsEnabled(false);
  6. setXmlOutput(serializer.write(json));
  7. }

代码示例来源:origin: kg.apc/jmeter-plugins-extras-libs

  1. private void convertToXML() {
  2. XMLSerializer serializer = new XMLSerializer();
  3. JSON json = JSONSerializer.toJSON(this.getJsonInput());
  4. serializer.setRootName("xmlOutput");
  5. serializer.setTypeHintsEnabled(false);
  6. setXmlOutput(serializer.write(json));
  7. }

代码示例来源:origin: jenkinsci/gerrit-trigger-plugin

  1. /**
  2. * Test ProjectListRefreshInterval zero value after upgrade from gerrit-trigger version 2.13.0 to 2.14.0.
  3. */
  4. @Test
  5. public void testProjectListRefreshIntervalZeroValue() {
  6. String formString = "{\"projectListRefreshInterval\":\"0\"}";
  7. JSONObject form = (JSONObject)JSONSerializer.toJSON(formString);
  8. Config config = new Config(form);
  9. assertEquals(Config.DEFAULT_PROJECT_LIST_REFRESH_INTERVAL, config.getProjectListRefreshInterval());
  10. }

相关文章