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 <https://cloud.google.com/>

   - Blog: glaforge.dev
   - Twitter: @glaforge <http://twitter.com/glaforge>
   - Mastodon: @glafo...@uwyn.net <http://%40glafo...@uwyn.net/>

Reply via email to