I'am relatively new to java and want to try out something new. At the moment I'am trying out the java framework play.
What I'am trying to do is to rewrite a little REST JSON Api written in php as a play rest service.
I'am using mongodb as datastore and therefore I installed morphia. Everything is working as expected. But I'am a little bit confused about the json result renderJSON() produces.
Here is the code of my model:
@AutoTimestamp
@Entity
public class Bookmark extends Model {
public String title;
public String url;
public String description;
public List tags;
public boolean is_private;
public Bookmark(String title,
String url,
String description,
String tags,
boolean is_private)
{
this.title = title;
this.url = url;
this.description = description;
this.tags = Arrays.asList(tags.split(" "));
this.is_private = is_private;
}
}
To retrieve all bookmarks I'am using the following method within the controller:
public static void listAll() {
List<Bookmark> bookmarks = Bookmark.findAll();
renderJSON(bookmarks);
}
Here is a line of the result:
[{"title":"Test","url":"http://www.google.de","description":"test","tags":["tag1","tag2","tag3","tag5","tag0209135913598"],"is_private":true,"_id":{"_time":1331202670,"_machine":-637116226,"_inc":989037616,"_new":false},"_created":1331202670469,"_modified":1331202670469,"blobFieldsTracker":{}}]
I'am a little bit confused now about the "_id"-Object with the attributes "_time", "_machine" and so on. And I'am also confused about "blobFieldsTracker".
For the attribute "_id" I would expect a mongoid. I could not find anything related to that within the docs or with google so my question is what I have to do to include the "real" mongoid within the json-string.