SCALA Lift - MongoDB JsonObjectField 将列表转换为 JSON
我在 mongodb 中有一个 json 对象字段,想知道是否有一种优雅的方法来映射以下列表:
List(("Label_1","Value_1"),("Label_2","Value_2"))
映射到 json 对象,例如:
var json = {
Label_1 : "Value_1",
Label_2 : "Value_2"
}
然后将对象保存到名为“thelist”的 json 对象字段中:
TheRecord.createRecord.title("Test Title").thelist(json).save
感谢您的帮助提前,非常感谢
I've got a json object field in mongodb and was wondering if there was an elegant way of mapping the following list:
List(("Label_1","Value_1"),("Label_2","Value_2"))
Into a json object like:
var json = {
Label_1 : "Value_1",
Label_2 : "Value_2"
}
And then saving the object into a json object field called "thelist":
TheRecord.createRecord.title("Test Title").thelist(json).save
Thanks for any help in advance, much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)