Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also encountered this problem - I did my best to document the fix on my website - See <a href="http://dalelotts.com/software-architect/grails" rel="nofollow">http://dalelotts.com/software-architect/grails</a></p> <p>In general the solution is to convert the JSON to a parameter map that can be used for data binding. More info on the site, including an annotation driven DomainClassMarshaller for JSON</p> <pre><code>protected Object readFromJson(Class type, InputStream entityStream, String charset) { def mapper = new ObjectMapper(); def parsedJSON = mapper.readValue(entityStream, typeRef); Map&lt;String, Object&gt; map = new HashMap&lt;&gt;(); parsedJSON.entrySet().each {Map.Entry&lt;String, Object&gt; entry -&gt; if (List.isAssignableFrom(entry.getValue().getClass())) { List values = (List) entry.getValue(); int limit = values.size() for (int i = 0; i &lt; limit; i++) { final theValue = values.get(i) map.put(entry.key + '[' + i + ']', theValue) appendMapValues(map, theValue, entry.key + '[' + i + ']' ) } } else { map.put(entry.key, entry.value); } } def result = type.metaClass.invokeConstructor(map) // Workaround for http://jira.codehaus.org/browse/GRAILS-1984 if (!result.id) { result.id = idFromMap(map) } result } private void appendMapValues(Map&lt;String, Object&gt; theMap, Object theValue, String prefix) { if (Map.isAssignableFrom(theValue.getClass())) { Map&lt;String, Object&gt; valueMap = (Map&lt;String, Object&gt;) theValue; for (Map.Entry&lt;String, Object&gt; valueEntry : valueMap.entrySet()) { theMap.put(prefix + '.' + valueEntry.key, valueEntry.value) appendMapValues(theMap, valueEntry.value, prefix + '.' + valueEntry.key) } } } </code></pre>
    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. This table or related slice is empty.
    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