简体   繁体   English

具有Scala驱动程序的MongoDB和AJAX的单个序列化

[英]Single serialization for MongoDB and AJAX with Scala drivers

I have a multi modular Scala application abd I need to implement: 我有一个多模块Scala应用程序abd,我需要实现:

  • Serialization towards JSON for Ajax 面向Ajax的JSON序列化
  • Serialization towards BSON format for MongoDB. MongoDB的BSON格式序列化。

My problem is that I would like to avoid using MongoDB JSON Api for converting to JSON. 我的问题是我想避免使用MongoDB JSON Api转换为JSON。

Is there a clever way to develop a single serialization layer and convert from JSON to BSON format for MongoDB ? 是否有一种聪明的方法来开发单个序列化层并将MongoDB从JSON转换为BSON格式?

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. 我认为您可以使用杰克逊映射器获取json,并使用Salat DAO(iirc使用相同的杰克逊映射器)将对象存储在Mongo中。 Salat only works with case classes, not sure if that's an issue. Salat仅适用于案例类,不确定是否存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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