Nested generic collections don't return jsonized values on toJson
See original GitHub issue+ private static class ClassWithDistinguishableFieldName {
+ private String distinguishableFieldName = "distinguishableFieldValue";
+ }
+
+ private static class ClassWithHashMapField {
+ private String a = "a";
+ private String b = "b";
+ HashMap<String, Object> c = new HashMap<String, Object>();
+
+ ClassWithHashMapField() {
+ c.put("someArray", Arrays.asList(new
ClassWithDistinguishableFieldName()));
+ }
+ }
+ ClassWithHashMapField o = new ClassWithHashMapField();
+ String json = gson.toJson(o);
json:
{"a":"a","b":"b","c":{"someArray":{}}}
expected:
{"a":"a","b":"b","c":{"someArray":[{"distinguishableFieldName":"distinguishableFieldValue"}]}}
This issue was blocking a project I am working on; so I attached a patch with a
test.
Original issue reported on code.google.com by masahji%...@gtempaccount.com
on 28 Jun 2010 at 2:47
Issue Analytics
- State:
- Created 9 years ago
- Comments:14
Top Results From Across the Web
(de)serialising Nested Generics in Jackson - Stack Overflow
When Jackson is deserializing your JSON into an object of type A , it sees the following when deserializing for its B field....
Read more >Parsing JSON with Circe | Baeldung on Scala
As a result, we get either a ParsingError or a Json object. We'll then use the match statement to distinguish between the returned...
Read more >Nested JSON - HTTPie 3.2.1 (latest) docs
This tells HTTPie to create an array in the given path (if there is not one already), and append the given value to...
Read more >Migrate from Newtonsoft.Json to System.Text.Json - .NET
Deserialize JSON null literal to non-nullable value types ... NET Core, you don't need to do anything to get behavior like Newtonsoft.Json ....
Read more >Gson — Mapping of Nested Objects - Future Studio
Getting Started with Java-JSON Serialization & Deserialization ... We don't want you to get bored, so we're going to move away from the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Original comment by
gianmarco.gherardi
on 13 Apr 2011 at 5:43Original comment by
radio...@ya.ru
on 28 Jul 2011 at 11:30