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() }
}
```


<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Sep 5, 2023 at 2:13 AM Guillaume Laforge <glafo...@gmail.com> wrote:
>
> 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 be treated like POGOs and thus serialize the same way like 
> in my example above? Or is there a good reason why this is not the case?
>
> Guillaume
>
> --
> Guillaume Laforge
> Apache Groovy committer
> Developer Advocate @ Google Cloud
>
> Blog: glaforge.dev
> Twitter: @glaforge
> Mastodon: @glafo...@uwyn.net

Reply via email to