Java - BasicDbObject - Spring View Support

82 views
Skip to first unread message

Saj

unread,
Nov 13, 2012, 2:58:45 PM11/13/12
to mongod...@googlegroups.com
Is there any built-in support for BasicDbObject and its ilk in Spring MVC for rendering JSON views?

Octavian Covalschi

unread,
Jan 30, 2013, 8:55:22 AM1/30/13
to mongod...@googlegroups.com
Just to add my 2 cents since I'm  working with Spring MVC and MongoDB right now...

1. With Spring MVC you don't have to deal directly with BasicDBObject, thanks to spring-data-mongodb you can map your domains with your collections.

2. Since you have a mapped domain object in your hand, you can use jackson to render it as json, just add 'org.codehaus.jackson:jackson-mapper-asl:1.9.11' to your dependencies and @ResponseBody to your controller method. Here is an example, a bit outdated but it works. http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-example/


On Wed, Jan 30, 2013 at 7:06 AM, Trisha Gee <trish...@10gen.com> wrote:
I don't know the internals of Spring MVC, but it's worth considering that BasicDBObject is actually a Map implementation, not specifically a JSON object.  So if Spring supports JSON-shaped objects, it might not apply to BasicDBObject.

However, BasicDBObject can be turned into a JSON String via com.mongodb.util.JSON.serialize.  So if Spring MVC supports JSON strings, then it will be able to render BasicDBObject.


On Tuesday, November 13, 2012 7:58:45 PM UTC, Saj wrote:
Is there any built-in support for BasicDbObject and its ilk in Spring MVC for rendering JSON views?

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages