serialization - Serializing Joda DateTime using groovy.json -
i have simple pojo class fueling want serialize json using built in groovy json library. application halts when trying serialize. class fueling { int id; int mileage; double amount; double cost; datetime datetime; string userid; } the following tests renders java.lang.stackoverflowerror: @test void parsejoda(){ def fueling = new fueling(amount: 1.0, cost: 2.3, mileage: 123, datetime: datetime.now(datetimezone.utc)); def jsonf = jsonoutput.tojson(fueling); } how can make serialization work? edit: json data persisting , not display purpuses, actual serialization result format not important long able deserialized again given don't care format, 1 simple workaround use maps groovy json api input/output , add in little code translate domain objects , maps. serializing you can use map returned getproperties as-is 2 modifications: converting datetime instance it's long millisecond representation , removing class entry (which lead memory errors ...