johnzon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: prettification
Date Mon, 12 Oct 2015 08:20:04 GMT
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 <hendrikdev22@gmail.com>:

> 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
> <rmannibucau@gmail.com> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message