本文整理了Java中org.apache.jena.atlas.json.JSON.write()
方法的一些代码示例,展示了JSON.write()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.write()
方法的具体详情如下:
包路径:org.apache.jena.atlas.json.JSON
类名称:JSON
方法名:write
[英]Write out a JSON value - pass a JSON Object to get legal exchangeable JSON
[中]写出一个JSON值-传递一个JSON对象以获得合法的可交换JSON
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Write out a JSON value to - pass a JSON Object to get legal exchangeable JSON */
public static void write(JsonValue jValue)
{
write(IndentedWriter.stdout, jValue) ;
}
}
代码示例来源:origin: apache/jena
/** Write out a JSON value - pass a JSON Object to get legal exchangeable JSON */
public static void write(JsonValue jValue) {
write(IndentedWriter.stdout, jValue) ;
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-server-local
private static byte[] jsonBytes(JsonValue json) {
ByteArrayOutputStream out = new ByteArrayOutputStream(8*1024);
JSON.write(out, json);
return out.toByteArray();
}
代码示例来源:origin: apache/jena
private static void doJsonQuery(Prologue prologue, QueryExecution queryExecution, ResultsFormat outputFormat) {
JsonArray results = queryExecution.execJson();
JSON.write(System.out, results);
}
代码示例来源:origin: apache/jena
/** Write to a file */
public static void write(String filename, StoreParams params) {
try (OutputStream out = new FileOutputStream(filename);
OutputStream out2 = new BufferedOutputStream(out); ) {
JsonObject object = encodeToJson(params) ;
JSON.write(out2, object) ;
out2.write('\n') ;
}
catch (IOException ex) { IO.exception(ex); }
}
代码示例来源:origin: apache/jena
/** Write to a file */
public static void write(String filename, StoreParams params) {
try (OutputStream out = new FileOutputStream(filename);
OutputStream out2 = new BufferedOutputStream(out); ) {
JsonObject object = encodeToJson(params) ;
JSON.write(out2, object) ;
out2.write('\n') ;
}
catch (IOException ex) { IO.exception(ex); }
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-cmds
public static void writeJSON(DeltaServerConfig config, String file) {
IOX.run(()->{
JsonObject obj = config.asJSON();
try (OutputStream out = Files.newOutputStream(Paths.get(file))) {
JSON.write(out, obj);
}});
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
/** Write out a JSON value - pass a JSON Object to get legal exchangeable JSON */
public static void write(OutputStream output, JsonValue jValue)
{
IndentedWriter iOut = new IndentedWriter(output) ;
write(iOut, jValue) ;
iOut.flush() ;
}
代码示例来源:origin: apache/jena
/** JsonValue to a formatted, multiline string */
public static String toString(JsonValue jValue) {
try ( IndentedLineBuffer b = new IndentedLineBuffer() ) {
JSON.write(b, jValue);
return b.asString() ;
}
}
代码示例来源:origin: apache/jena
/** Write out a JSON value - pass a JSON Object to get legal exchangeable JSON */
public static void write(OutputStream output, JsonValue jValue) {
IndentedWriter iOut = new IndentedWriter(output) ;
write(iOut, jValue) ;
iOut.flush() ;
}
代码示例来源:origin: apache/jena
/** Send a JSON value as a 200 response. Null object means no response body and no content-type headers. */
public static void sendJson(HttpAction action, JsonValue v) {
if ( v == null )
return ;
try {
HttpServletResponse response = action.response ;
ServletOutputStream out = response.getOutputStream() ;
response.setContentType(WebContent.contentTypeJSON);
response.setCharacterEncoding(WebContent.charsetUTF8) ;
IndentedWriter iOut = new IndentedWriter(out) ;
JSON.write(iOut, v) ;
// Make sure we end with a newline.
iOut.ensureStartOfLine();
iOut.flush() ;
out.flush() ;
} catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
}
代码示例来源:origin: org.apache.jena/jena-fuseki-core
/** Send a JSON value as a 200 response. Null object means no response body and no content-type headers. */
public static void sendJson(HttpAction action, JsonValue v) {
if ( v == null )
return ;
try {
HttpServletResponse response = action.response ;
ServletOutputStream out = response.getOutputStream() ;
response.setContentType(WebContent.contentTypeJSON);
response.setCharacterEncoding(WebContent.charsetUTF8) ;
IndentedWriter iOut = new IndentedWriter(out) ;
JSON.write(iOut, v) ;
// Make sure we end with a newline.
iOut.ensureStartOfLine();
iOut.flush() ;
out.flush() ;
} catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
}
代码示例来源:origin: apache/jena
/** JsonValue to a string with no newlines */
public static String toStringFlat(JsonValue jValue) {
try ( IndentedLineBuffer b = new IndentedLineBuffer() ) {
b.setFlatMode(true);
JSON.write(b, jValue);
return b.asString() ;
}
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-base
/** Write out a JSON value - pass a JSON Object to get legal exchangeable JSON */
private static void writeFlat(OutputStream output, JsonValue jValue) {
IndentedWriter iOut = new IndentedWriter(output) ;
iOut.setFlatMode(true);
JSON.write(iOut, jValue) ;
iOut.flush() ;
}
代码示例来源:origin: apache/jena
private void description(HttpAction action) throws IOException {
ServletOutputStream out = action.response.getOutputStream() ;
action.response.setContentType(contentTypeJSON);
action.response.setCharacterEncoding(charsetUTF8) ;
JsonBuilder builder = new JsonBuilder() ;
builder.startObject() ;
describeServer(builder, action.request.getLocalPort()) ;
describeDatasets(builder, action.getDataAccessPointRegistry()) ;
builder.finishObject() ;
JsonValue v = builder.build() ;
JSON.write(out, v) ;
out.println() ;
out.flush() ;
}
代码示例来源:origin: org.apache.jena/jena-fuseki-webapp
private void description(HttpAction action) throws IOException {
ServletOutputStream out = action.response.getOutputStream() ;
action.response.setContentType(contentTypeJSON);
action.response.setCharacterEncoding(charsetUTF8) ;
JsonBuilder builder = new JsonBuilder() ;
builder.startObject() ;
describeServer(builder, action.request.getLocalPort()) ;
describeDatasets(builder, action.getDataAccessPointRegistry()) ;
builder.finishObject() ;
JsonValue v = builder.build() ;
JSON.write(out, v) ;
out.println() ;
out.flush() ;
}
代码示例来源:origin: apache/jena
public static void main(String... args)
{
if ( args.length == 0 )
args = new String[] {"-"} ;
try {
for ( String fn : args )
{
JsonValue json =null ;
try {
json = JSON.readAny(fn) ;
} catch (JsonParseException ex)
{
String name = fn.equals("-") ? "<stdin>" : fn ;
System.err.println(name+": "+JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn())) ;
continue ;
}
JSON.write(IndentedWriter.stdout, json) ;
IndentedWriter.stdout.ensureStartOfLine() ;
}
} finally { IndentedWriter.stdout.flush() ; }
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-cmds
private void roundTrip(DeltaServerConfig c) {
JsonObject obj = c.asJSON();
DeltaServerConfig c2 = DeltaServerConfig.create(obj);
if ( ! c.equals(c2) ) {
System.out.println("c : "+c.zkMode);
System.out.println("c2 : "+c2.zkMode);
JSON.write(obj);
JSON.write(c2.asJSON());
}
assertEquals(c, c2);
}
}
代码示例来源:origin: org.apache.clerezza.ext/org.apache.jena.jena-arq
public static void main(String... args)
{
if ( args.length == 0 )
args = new String[] {"-"} ;
try {
for ( String fn : args )
{
JsonValue json =null ;
try {
json = JSON.readAny(fn) ;
} catch (JsonParseException ex)
{
String name = fn.equals("-") ? "<stdin>" : fn ;
System.err.println(name+": "+JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn())) ;
continue ;
}
JSON.write(IndentedWriter.stdout, json) ;
IndentedWriter.stdout.ensureStartOfLine() ;
}
} finally { IndentedWriter.stdout.flush() ; }
}
代码示例来源:origin: org.seaborne.rdf-delta/rdf-delta-fuseki-server
private void writeConf(BackupConfig cfg) {
JsonObject obj = JSONX.buildObject(b->{
b .pair(jPort, cfg.port)
.key(jLogs).startArray();
cfg.logs.forEach(a->
b.startObject().pair(jName, a.name).pair(jDir, a.dir).pair(jFile, a.file).finishObject()
);
b.finishArray();
});
JSON.write(System.out, obj);
}
}
内容来源于网络,如有侵权,请联系作者删除!