fixed on separate branch https://github.com/apache/incubator-johnzon/commit/f1392c2f02b0aeba2b41aed19e3b8625005ea9a1 i took the chance and rewrote the generator, it was too complex imho can someone review and merge this into master if ok?
On Mon, Oct 12, 2015 at 10:49 AM, Hendrik Dev <[email protected]> wrote: > ok, with that i can reproduce, will have a look today .... > > @Test > public void prettySimpleStructure() { > > final JsonWriterFactory writerFactory = > Json.createWriterFactory(new HashMap<String, Object>() { > { > put(JsonGenerator.PRETTY_PRINTING, true); > } > }); > > StringWriter buffer = new StringWriter(); > > try (final JsonWriter writer = > writerFactory.createWriter(buffer)) { > > > writer.write(Json.createObjectBuilder().add("firstName", > "John").build()); > > } > assertEquals("{\n" + " \"firstName\":\"John\"\n" + "}", > buffer.toString()); > } > > On Mon, Oct 12, 2015 at 10:20 AM, Romain Manni-Bucau > <[email protected]> wrote: >> I used: >> >> try (final JsonReader reader = readerFactory.createReader(new >> ByteArrayInputStream(someString.getBytes()))) { >> try (final JsonWriter writer = writerFactory.createWriter(buffer)) >> { // buffer is a StringWriter >> writer.write(reader.read()); >> } >> } >> >> >> >> Romain Manni-Bucau >> @rmannibucau <https://twitter.com/rmannibucau> | Blog >> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> >> | >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber >> <http://www.tomitribe.com> >> >> 2015-10-12 10:18 GMT+02:00 Hendrik Dev <[email protected]>: >> >>> i can look into this but cannot reproduce >>> >>> @Test >>> public void prettySimple() { >>> final ByteArrayOutputStream baos = new ByteArrayOutputStream(); >>> final JsonGenerator generator = >>> Json.createGeneratorFactory(new HashMap<String, Object>() {{ >>> put(JsonGenerator.PRETTY_PRINTING, true); >>> }}).createGenerator(baos); >>> >>> generator.writeStartObject().write("firstName", >>> "John").writeEnd().close(); >>> assertEquals("{\n" + >>> >>> " \"firstName\":\"John\"\n" + >>> >>> "}", new String(baos.toByteArray())); >>> >>> } >>> >>> Can you provide a failing test? >>> >>> On Sun, Oct 11, 2015 at 9:33 PM, Romain Manni-Bucau >>> <[email protected]> wrote: >>> > Hi guys, >>> > >>> > prettifying a json with johnzon leads to empty lines, what do you think >>> > about it? I'm tempted t get rid of them. >>> > >>> > Here is a sample: >>> > >>> > ---- >>> > {"foo":"bar"} >>> > ---- >>> > >>> > -> with johnzon >>> > >>> > ----- >>> > >>> > { >>> > >>> > "foo":"bar" >>> > } >>> > ---- >>> > >>> > >>> > -> expected >>> > >>> > ----- >>> > { >>> > "foo":"bar" >>> > } >>> > ---- >>> > >>> > If anyone wants to work on it happy to let you hack or I will tackle it >>> > next week probably. >>> > >>> > Romain Manni-Bucau >>> > @rmannibucau <https://twitter.com/rmannibucau> | Blog >>> > <http://rmannibucau.wordpress.com> | Github < >>> https://github.com/rmannibucau> | >>> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber >>> > <http://www.tomitribe.com> >>> >>> >>> >>> -- >>> Hendrik Saly (salyh, hendrikdev22) >>> @hendrikdev22 >>> PGP: 0x22D7F6EC >>> > > > > -- > Hendrik Saly (salyh, hendrikdev22) > @hendrikdev22 > PGP: 0x22D7F6EC -- Hendrik Saly (salyh, hendrikdev22) @hendrikdev22 PGP: 0x22D7F6EC
