org.json.simple.JSONObject.writeJSONString()方法的使用及代码示例

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

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

JSONObject.writeJSONString介绍

[英]Encode a map into JSON text and write it to out. If this map is also a JSONAware or JSONStreamAware, JSONAware or JSONStreamAware specific behaviours will be ignored at this top level.
[中]将映射编码为JSON文本并将其写入输出。如果此映射也是一个JSONAware或JSONStreamAware,则此顶层将忽略JSONAware或JSONStreamAware特定的行为。

代码示例

代码示例来源:origin: com.googlecode.json-simple/json-simple

public void writeJSONString(Writer out) throws IOException{
  writeJSONString(this, out);
}

代码示例来源:origin: com.googlecode.json-simple/json-simple

JSONObject.writeJSONString((Map)value, out);
return;

代码示例来源:origin: ralfstx/minimal-json

@Override
public void writeToWriter(Object model, Writer writer) throws Exception {
 ((JSONObject)model).writeJSONString(writer);
}

代码示例来源:origin: i2p/i2p.i2p

public void writeJSONString(Writer out) throws IOException{
  writeJSONString(this, out);
}

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

public static void encode(Map<String, Object> obj, Object output) throws IOException {
    Writer w = toWriter(output);
    JSONObject.writeJSONString(obj, w);
    w.flush();
  }
}

代码示例来源:origin: jitsi/jitsi-videobridge

jsonObject.writeJSONString(response.getWriter());

代码示例来源:origin: i2p/i2p.i2p

JSONObject.writeJSONString((Map)value, out);
return;

代码示例来源:origin: jitsi/jitsi-videobridge

statisticsJSONObject.writeJSONString(writer);

代码示例来源:origin: jitsi/jitsi-videobridge

conferenceJSONObject.writeJSONString(response.getWriter());

代码示例来源:origin: jitsi/jitsi-videobridge

responseJSONObject.writeJSONString(
    response.getWriter());

代码示例来源:origin: jitsi/jitsi-videobridge

responseJSONObject.writeJSONString(
    response.getWriter());

代码示例来源:origin: fangyidong/json-simple

public void writeJSONString(Writer out) throws IOException{
  writeJSONString(this, out);
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-httpfs

@Override
public void writeTo(Map map, Class<?> aClass, Type type, Annotation[] annotations,
          MediaType mediaType, MultivaluedMap<String, Object> stringObjectMultivaluedMap,
          OutputStream outputStream) throws IOException, WebApplicationException {
 Writer writer =
   new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
 JSONObject.writeJSONString(map, writer);
 writer.write(ENTER);
 writer.flush();
}

代码示例来源:origin: xXKeyleXx/MyPet

@SuppressWarnings("unchecked")
protected void save() {
  try (OutputStreamWriter oos = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(cacheFile)))) {
    JSONObject cacheObject = new JSONObject();
    cacheObject.put("expMap", expMap);
    cacheObject.put("version", version);
    cacheObject.put("calculator", calculator);
    cacheObject.writeJSONString(oos);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}

代码示例来源:origin: org.geotools/gt-geojson

public static void encode(Map<String,Object> obj, Object output) throws IOException {
    Writer w = toWriter(output);
    JSONObject.writeJSONString(obj, w);
    w.flush();
  }
}

代码示例来源:origin: Lambda-3/Indra

public static void writeMapAsJson(Map<String, Object> map, File file) throws IOException {
  JSONObject metadataJson = toJSONObject(map);
  Writer writer = new FileWriter(file);
  metadataJson.writeJSONString(writer);
  writer.close();
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs-httpfs

@Override
public void writeJSONString(Writer out) throws IOException {
 getJSON().writeJSONString(out);
}

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

@Override
public void encode(Object value, OutputStream os) throws Exception {
  PagedUniqueProcess.Results result = (PagedUniqueProcess.Results) value;
  JSONObject obj = new JSONObject();
  obj.put("featureTypeName", result.getFeatureTypeName());
  obj.put("fieldName", result.getFieldName());
  obj.put("size", result.getSize());
  obj.put("values", result.getValues());
  Writer writer = new OutputStreamWriter(os);
  obj.writeJSONString(writer);
  writer.flush();
}

代码示例来源:origin: org.nuxeo.connect.tools/nuxeo-connect-tools-report-core

void run(OutputStream sink) {
  try {
    JmxRequest request = JmxRequestFactory.createPostRequest(pRequestMap, config.getProcessingParameters(pParams));
    JSONObject json = manager.handleRequest(request);
    OutputStreamWriter writer = new OutputStreamWriter(sink);
    json.writeJSONString(writer);
    writer.flush();
  } catch (JMException | IOException cause) {
    throw new AssertionError("Cannot invoke jolokia", cause);
  }
}

代码示例来源:origin: HubSpot/SlimFast

public static void writeArtifactsToJson(File outputFile, S3ArtifactWrapper wrapper) throws IOException {
 JSONObject json = new JSONObject();
 JSONArray artifacts = new JSONArray();
 for (S3Artifact artifact : wrapper.getArtifacts()) {
  artifacts.add(toJsonObject(artifact));
 }
 json.put("prefix", wrapper.getPrefix());
 json.put("artifacts", artifacts);
 try (Writer writer = newWriter(outputFile)) {
  json.writeJSONString(writer);
  writer.flush();
 }
}

相关文章