Records support in JSON

2023-09-04 Thread Guillaume Laforge
Hi, I was a bit surprised by this behavior with serializing records in JSON. I was expecting this assertion to pass: import groovy.json.JsonOutput record Person(String name) {} assert JsonOutput.toJson([new Person('Guillaume')]) == '[{"name":"Guillaume"}]' Instead, I got [{}] Shouldn't records

Re: Records support in JSON

2023-09-04 Thread Paul King
We aren't picking up the metabean properties for the record correctly. Would you like to file a bug report? Workarounds are to call "toMap()" (or *.toMap() on the list), or do something like: ``` @AutoImplement record Person(String name) implements Map { Set entrySet() { toMap().entrySet() } } `