I have the following POJO:
public class Widget { private String fizz; private String buzz; private String foo;
In my code, I am trying to convert List<List<Widget>> to JSON using the Java JSON library (however, I also accept any responses as well using GSON).
Here is my code:
Fingerprints:
[ [ { "fizz": "Yes", "buzz": "Never", "foo": "Always" }, { "fizz": "Sometimes", "buzz": "Always", "foo": "Pending" } ] ]
While I want JSON to display as:
"widgetGroups": [ "widgetGroup": [ "widget": { "fizz": "Yes", "buzz": "Never", "foo": "Always" }, "widget": { "fizz": "Sometimes", "buzz": "Always", "foo": "Pending" } ] ]
In other words, I want all lists, as well as every widget , to be "named." My first concern, however, is that this may not be the correct JSON. When I insert this 2nd (desired) JSON snippet in jsonlint.org , I get a parser error.
So first, I ask if anyone can be so kind as to indicate what my desired JSON should be in order to be correct; and then the second , if someone can help me massage my widgetGroups list widgetGroups that either Java JSON or GSON can produce the desired result. Thanks in advance!
source share