DonaldDu / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Lenient JsonWriter should allow multiple top level objects #397

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

JsonWriter jsonWriter = new JsonWriter( new StringWriter() );
jsonWriter.setLenient( true );
jsonWriter.beginObject();
jsonWriter.endObject);
jsonWriter.beginObject();

What is the expected output? What do you see instead?

Expected to write additional objects.  Instead, an IllegalStateException is 
thrown: "JSON must have only one top-level value."

What version of the product are you using? On what operating system?

gson-2.1

Please provide any additional information below.

Lenient JsonReader allows this, it would seem that the writer should as well.

Original issue reported on code.google.com by kpha...@gmail.com on 3 Jan 2012 at 8:46

GoogleCodeExporter commented 9 years ago
Here is a simple patch to fix the issue.  It breaks one unit test but appears 
to work in practice.  Can someone with more knowledge of the product take a 
look and make sure I'm not overlooking something.

Original comment by kpha...@gmail.com on 3 Jan 2012 at 8:50

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the helpful report. We'll fix this in the next release.

Original comment by limpbizkit on 4 Jan 2012 at 1:26

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1124.

Original comment by limpbizkit on 12 Feb 2012 at 8:42