Closed GoogleCodeExporter closed 9 years ago
Added tests in r637
// Works, but prints "null" (not expected, expected: "[]")
System.out.println(new Gson().toJson(new Object[] { null }));
Gson indeed prints the correct answer of [null]. new Object[]{null} is not a
null array. It is an array containing a single object of value null. Since
arrays are ordered, nulls must always be printed.
// java.lang.IllegalArgumentException
System.out.println(new Gson().toJson(new Object[] { new Object() }));
Gson has no way to convert the Object into anything meaningful and hence you
get the exception.
Original comment by inder123
on 3 Nov 2010 at 12:18
Original issue reported on code.google.com by
hq4ever
on 13 Oct 2010 at 7:35Attachments: