2

I am trying to create a serialization layer which allows me to:

  • Store my classes in a MongoDB data source
  • Convert them to JSON to use them in a REST API.

Some classes are clearly not case classes (because they are inherited from a Java codebase) and I would have to write ad-hoc code for that. Is registering a BSON Hook for my non standard type the correct approach, and does it provide Json serialization?

Edmondo
  • 19,559
  • 13
  • 62
  • 115

1 Answers1

3

Salat maintainer here.

You might prefer to create a Salat custom transformer instead of registering a BSON hook with Casbah.

See simple example and spec.

If you run into any issues, feel free to ping the mailing list with a small sample Github project that demonstrates what isn't working.

prasinous
  • 798
  • 3
  • 6
  • I verified that the transformer does not work if the input class is not a case class, so my problem is not solved yet. Would it make sense to write a CustomTransformer from a Java class to DBOBject directly? – Edmondo Jul 08 '13 at 14:51