简体   繁体   中英

Single serialization for MongoDB and AJAX with Scala drivers

I have a multi modular Scala application abd I need to implement:

  • Serialization towards JSON for Ajax
  • Serialization towards BSON format for MongoDB.

My problem is that I would like to avoid using MongoDB JSON Api for converting to JSON.

Is there a clever way to develop a single serialization layer and convert from JSON to BSON format for MongoDB ?

I think you can use the jackson mapper to get json, and use Salat DAO (which iirc uses the same jackson mapper) to store your objects in Mongo. Salat only works with case classes, not sure if that's an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM