@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(this, null); }
public TweetBench() { try { MappingJsonFactory jf = new MappingJsonFactory(); InputStream json = TweetBench.class.getClassLoader().getResourceAsStream("tweet.json"); new ArrayList<>(singletonList(new JsonMap(jf.createParser(json).readValueAsTree()))); } catch (IOException e) { throw new RuntimeException(e); } }
public class ParseJsonSample { public static void main(String[] args) throws Exception { JsonFactory f = new MappingJsonFactory(); JsonParser jp = f.createJsonParser(new File(args[0])); JsonToken current;
JsonFactory f = new MappingJsonFactory(); PointSet ret = new PointSet(n); int index = 0;
private void output(Node invert) throws IOException { MappingJsonFactory jf = new MappingJsonFactory(); StringWriter out = new StringWriter(); JsonGenerator jg = jf.createJsonGenerator(out); writeNode(jg, invert); jg.flush(); System.out.println(out.toString()); }
MappingJsonFactory jf = new MappingJsonFactory(); JsonNode jsonNode = jf.createParser(json).readValueAsTree(); StringWriter sw2 = new StringWriter();
protected Object getScope() throws IOException { MappingJsonFactory jf = new MappingJsonFactory(); InputStream json = getClass().getClassLoader().getResourceAsStream("hogan.json"); final Map node = (Map) toObject(jf.createJsonParser(json).readValueAsTree()); System.out.println(node); return new Object() { int uid = 0; List tweets = new ArrayList() {{ for (int i = 0; i < 50; i++) { add(node); } }}; }; }
_jsonFactory = new MappingJsonFactory(this); } else { _jsonFactory = jf;
public void testComplex() throws MustacheException, IOException { StringWriter json = new StringWriter(); MappingJsonFactory jf = new MappingJsonFactory(); final JsonGenerator jg = jf.createJsonGenerator(json); jg.writeStartObject(); final JsonCapturer captured = new JsonCapturer(jg); MustacheFactory c = new DefaultMustacheFactory(root) { @Override public MustacheVisitor createMustacheVisitor() { return new CapturingMustacheVisitor(this, captured); } }; Mustache m = c.compile("complex.html"); StringWriter sw = new StringWriter(); m.execute(sw, new ComplexObject()); jg.writeEndObject(); jg.flush(); assertEquals(getContents(root, "complex.txt"), sw.toString()); JsonNode jsonNode = jf.createJsonParser(json.toString()).readValueAsTree(); Object o = JsonInterpreterTest.toObject(jsonNode); sw = new StringWriter(); m = createMustacheFactory().compile("complex.html"); m.execute(sw, o); assertEquals(getContents(root, "complex.txt"), sw.toString()); }
public static void buildJsonReport(List<Playbook> playbooks, File resultFile) throws Exception { JsonFactory jf = new MappingJsonFactory(); try (JsonGenerator jg = jf.createGenerator(resultFile, JsonEncoding.UTF8)) { jg.writeStartObject(); jg.writeFieldName("playbooks"); jg.writeObject(playbooks); jg.writeEndObject(); } catch (Exception e) { throw e; } }
@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(null); }
@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(null); }
public JsonWriter(final Job job, final File coverallsFile) throws IOException { File directory = coverallsFile.getParentFile(); if (!directory.exists()) { directory.mkdirs(); } this.job = job; this.coverallsFile = coverallsFile; this.generator = new MappingJsonFactory().createGenerator(coverallsFile, JsonEncoding.UTF8); }
public JsonWriter(final Job job, final File coverallsFile) throws IOException { File directory = coverallsFile.getParentFile(); if (!directory.exists()) { directory.mkdirs(); } this.job = job; this.coverallsFile = coverallsFile; this.generator = new MappingJsonFactory().createGenerator(coverallsFile, JsonEncoding.UTF8); }
@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(null); }
@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(this, null); }
@Override public JsonFactory copy() { _checkInvalidCopy(MappingJsonFactory.class); // note: as with base class, must NOT copy mapper reference return new MappingJsonFactory(this, null); }
public JsonFileReader(File inputFile, BufferAllocator allocator) throws JsonParseException, IOException { super(); this.allocator = allocator; MappingJsonFactory jsonFactory = new MappingJsonFactory(); this.parser = jsonFactory.createParser(inputFile); // Allow reading NaN for floating point values this.parser.configure(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS, true); }
private DocumentSource createDocumentSource() { final InputStream inputStream = _resource.read(); try { final MappingJsonFactory jsonFactory = new MappingJsonFactory(); final JsonParser parser = jsonFactory.createParser(inputStream); logger.debug("Created JSON parser for resource: {}", _resource); return new JsonDocumentSource(parser, _resource.getName()); } catch (Exception e) { FileHelper.safeClose(inputStream); throw new MetaModelException("Unexpected error while creating JSON parser", e); } }
public JsonFileWriter(File outputFile, JSONWriteConfig config) throws IOException { MappingJsonFactory jsonFactory = new MappingJsonFactory(); this.generator = jsonFactory.createGenerator(outputFile, JsonEncoding.UTF8); if (config.pretty) { DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter(); prettyPrinter.indentArraysWith(NopIndenter.instance); this.generator.setPrettyPrinter(prettyPrinter); } // Allow writing of floating point NaN values not as strings this.generator.configure(JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS, false); }