/** * Writes the given JSON-LD Object out to a String, using indentation and * new lines to improve readability. * * @param jsonObject * The JSON-LD Object to serialize. * @return A JSON document serialised to a String. * @throws JsonGenerationException * If there is a JSON error during serialization. * @throws IOException * If there is an IO error during serialization. */ public static String toPrettyString(Object jsonObject) throws JsonGenerationException, IOException { final StringWriter sw = new StringWriter(); writePrettyPrint(sw, jsonObject); return sw.toString(); }
/** * Writes the given JSON-LD Object out to a String, using indentation and * new lines to improve readability. * * @param jsonObject * The JSON-LD Object to serialize. * @return A JSON document serialised to a String. * @throws JsonGenerationException * If there is a JSON error during serialization. * @throws IOException * If there is an IO error during serialization. */ public static String toPrettyString(Object jsonObject) throws JsonGenerationException, IOException { final StringWriter sw = new StringWriter(); writePrettyPrint(sw, jsonObject); return sw.toString(); }
/** * Writes the given JSON-LD Object out to a String, using indentation and * new lines to improve readability. * * @param jsonObject * The JSON-LD Object to serialize. * @return A JSON document serialised to a String. * @throws JsonGenerationException * If there is a JSON error during serialization. * @throws IOException * If there is an IO error during serialization. */ public static String toPrettyString(Object jsonObject) throws JsonGenerationException, IOException { final StringWriter sw = new StringWriter(); writePrettyPrint(sw, jsonObject); return sw.toString(); }
/** * Starts writing the BDIO document. This must be called exactly once, <em>before</em> starting to call {@code next} * to write individual nodes. */ public void start() throws IOException { checkState(started.compareAndSet(false, true), "already started"); // Write just the full metadata as the first entry out = entryStreams.newStream(); Writer writer = new OutputStreamWriter(out, UTF_8); JsonUtils.writePrettyPrint(writer, metadata.asNamedGraph()); writer.flush(); }
logger.debug(" - prettyPrint: {}", prettyPrint); if (prettyPrint) { JsonUtils.writePrettyPrint(writer, output); } else { JsonUtils.write(writer, output);
logger.debug(" - prettyPrint: {}", prettyPrint); if (prettyPrint) { JsonUtils.writePrettyPrint(writer, output); } else { JsonUtils.write(writer, output);
logger.debug(" - prettyPrint: {}", prettyPrint); if (prettyPrint) { JsonUtils.writePrettyPrint(writer, output); } else { JsonUtils.write(writer, output);
@AfterClass public static void writeReport() throws JsonGenerationException, JsonMappingException, IOException, JsonLdError { // Only write reports if "-Dreport.format=..." is set String reportFormat = System.getProperty("report.format"); if (reportFormat != null) { reportFormat = reportFormat.toLowerCase(); if ("application/ld+json".equals(reportFormat) || "jsonld".equals(reportFormat) || "*".equals(reportFormat)) { System.out.println("Generating JSON-LD Report"); JsonUtils.writePrettyPrint( new OutputStreamWriter(new FileOutputStream(reportOutputFile + ".jsonld"), StandardCharsets.UTF_8), REPORT); } } }
private void serialize(Writer writer, DatasetGraph dataset, PrefixMap prefixMap, String baseURI, Context jenaContext) { try { Object obj = toJsonLDJavaAPI(getVariant(), dataset, prefixMap, baseURI, jenaContext); if (getVariant().isPretty()) { JsonUtils.writePrettyPrint(writer, obj) ; } else { JsonUtils.write(writer, obj) ; } writer.write("\n") ; } catch (JsonLdError | JsonMappingException | JsonGenerationException e) { throw new RiotException(e) ; } catch (IOException e) { IO.exception(e) ; } }
JsonUtils.writePrettyPrint(writer, output); } else { JsonUtils.write(writer, output);
JsonUtils.writePrettyPrint(writer, output);
JsonUtils.writePrettyPrint(writer, output);