Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, are you sure this is correct? The comment and code does not match .</p> <pre><code>// Returns a single List&lt;Widget&gt; with 2 Widgets in it... List&lt;List&lt;Widget&gt;&gt; widgetGroups = getWidgetGroups(); </code></pre> <p>Second, create a WidgetGroup class that will act as a container for a single WidgetGroup.</p> <pre><code>public class WidgetGroup { private String name; private List&lt;Widget&gt; widgets; public String getName() { return name; } public void setName(String name) { this.name = name; } public List&lt;Widget&gt; getWidgets() { return widgets; } public void setWidgets(List&lt;Widget&gt; widgets) { this.widgets = widgets; } } </code></pre> <p>This would be a valid JSON structure:</p> <pre><code>{ "widgetGroups" : [ { "widgetGroup": [ "widget": { "fizz": "Yes", "buzz": "Never", "foo": "Always" }, /*More widgets*/ ] }, /*More widget groups*/ ] } </code></pre> <p>Something like this should work:</p> <pre><code>Map&lt;String, List&lt;WidgetGroup&gt;&gt; widgetGroups = new HashMap&lt;String, List&lt;WidgetGroup&gt;&gt;(); WidgetGroup widgetGroup1 = getWidgetGroup(); // Just an assumption of one of your methods. WidgetGroup widgetGroup2 = getWidgetGroup(); // Just an assumption of one of your methods. List&lt;WidgetGroup&gt; widgetGroupList = new ArrayList&lt;WidgetGroup&gt;(); widgetGroupList.add(widgetGroup1); widgetGroupList.add(widgetGroup2); widgetGroups.put("widgetGroups", widgetGroupList); </code></pre> <p>Then you call <code>toJson()</code> on the map. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload