1

How can I (easily) serialize ceylon objects to json with jackson?

I assume it should work 'out of the box' - because the specification says:

"... Ceylon maps instance attributes to JavaBean properties, so naturally, every JavaBean property defined in Java is mapped to a Ceylon instance attribute...¨

And the same should work the other way around.

I do not show what I - unsuccessfully - tried, because that would add more noise than necessary, and I think there must be a simple solution - so I ask you to provide a simple example as answer.

I am not asking for the projects 'alabama' or 'jsonmapper' - because my question is not only about a practical solution to the problem of persisting objects but also about the relationship between ceylon objects and java beans.

  • It would be interesting to see what you tried, and why it didn't work. Note that in Ceylon 1.3.1 there is a new compiler mode that makes it easier to use annotation-driven Java frameworks in Ceylon. We've tested it with JAXB and it works great: https://ceylon-lang.org/documentation/1.3/reference/interoperability/ee-mode/ – Gavin King Nov 17 '16 at 10:01
  • The version I tried was 1.2.x. If EE-mode is made for such purposes - including serialization - this is obviously the (brand new) solution. I asked that question with some delay. It would be of great value if you could give a big picture (which is actually a small picture of something big) of persisting ceylon objects to file and to database. I have speculated on ceylon + database - for some obvious reason! – Redza Erdogan Nov 17 '16 at 15:06
  • 1
    @GavinKing when I tried serializing a Ceylon object to JSON using Jackson one year ago, I got an endless loop from String → iterate → Character → .integer → Integer → .predecessor → Integer → .predecessor → ... . – I don't have this project available anymore, though. – Paŭlo Ebermann Nov 17 '16 at 20:01
  • Right, and that's exactly one of the problems that the new `--ee` switch is supposed to solve. So if I were you I would try with `--ee` enabled. – Gavin King Nov 24 '16 at 19:06

0 Answers0