google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Create an entity from a json string feature #269

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
My use case is the client post a object to my server side, eg, I wanna 
to create a Story entry, it's a really complicated object to use a Map 
to present it. The Story entry will build in the client side as a JSON 
format. Then it is posted to my REST interface. The server side got 
the JSON, if I can translate the JSON to a entity I have defined, it 
was really easy to save this entity with Morphia. 

Original issue reported on code.google.com by lynn.ma...@gmail.com on 13 Apr 2011 at 4:15

GoogleCodeExporter commented 9 years ago
I will leave this to collect votes but I'm inclined not to add little helpers 
like this into the core library. It could make sense as an extension/wrapper.

You can easily write code using morphia to load the json string into a DBObject 
(using JSON.parse() ), and then convert that to an entity 
(Morphia/Mapper.fromDBObject(...) ).

Original comment by scotthernandez on 18 Jun 2011 at 11:58