You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. Create a Gson object with pretty printing: new
GsonBuilder().setPrettyPrinting().create();
2. Serialize an object containing a map.
What is the expected output? What do you see instead?
As pretty JSON: {"baz":{}"fizzle":"bar"}
As compact JSON: {"baz":{},"fizzle":"bar"}
What version of the product are you using? On what operating system?
1.2.3
Please provide any additional information below.
Here's a simple example that produces the output above and demonstrates the
problem:
package com.joelpm;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
public class App {
public static class Foo {
private Map<String,String> baz;
private String fizzle;
public Foo(String fizzle) {
this.baz = new HashMap<String,String>();
this.fizzle = fizzle;
}
}
public static void main(String[] args) {
Foo quux = new Foo("bar");
Gson gsonPretty = new GsonBuilder().setPrettyPrinting().create();
Gson gsonRegular = new GsonBuilder().create();
System.out.println("As pretty JSON: " + gsonPretty.toJson(quux));
System.out.println("As compact JSON: " + gsonRegular.toJson(quux));
}
}
Original issue reported on code.google.com by joel.me...@gmail.com on 12 Jan 2009 at 10:52
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
joel.me...@gmail.com
on 12 Jan 2009 at 10:52The text was updated successfully, but these errors were encountered: