fleece-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: JsonGenerator chaining enforced
Date Fri, 27 Jun 2014 15:36:55 GMT
Yes this is the case (see the mapper impl).

But you are right. Spec mandates it to be a single instance.

I think the easiest will be to get a JsonGeneratorFacade delegate to
JsonGenerateImpl (names are just to give the idea). Wouldn't need a lot of
dev.

Do you want to have a try?



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-27 17:34 GMT+02:00 Hendrik Dev <hendrikdev22@gmail.com>:

> Hi,
>
> don't know if this is an issue but it seems that the JsonGenerator
> must be used in fluent/chaining style:
>
>
>     @Test
>     public void generateChain() {
>         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         final JsonGenerator generator = Json.createGenerator(baos);
>         generator.writeStartObject().write("firstName",
> "John").writeEnd().close();
>         assertEquals("{\"firstName\":\"John\"}", new
> String(baos.toByteArray()));
>     } //this testcase works well
>
>     @Test
>     public void generateNonChain() {
>         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
>         final JsonGenerator generator = Json.createGenerator(baos);
>         generator.writeStartObject();
>         generator.write("firstName", "John");
>         generator.writeEnd();
>         generator.close();
>         assertEquals("{\"firstName\":\"John\"}", new
> String(baos.toByteArray()));
>     } //this fails because of a leading and dangling comma
>
> API spec say: -can- be chained
>
> Thanks
> Hendrik
>

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