我正在为托管在GAE上的Restlet搜索开源项目,并试图用restlet + objectify来找出CRUD操作。在我当前的应用程序中,我使用了以下方法:
我不太清楚如何在restlet中使用JSON表示来请求响应。
因此,如果在google代码或github上存在开源项目,它将有所帮助。
谢谢
发布于 2011-01-27 22:05:41
我在一个项目中使用了同样的技术。如果您正在寻找JSON表示示例,下面的代码可能会有所帮助。我使用葛森来处理JSON序列化/反序列化:
public Foo() {
private String name;
public Foo() {};
public Foo(String name) {
this.name = name;
}
public String toJson() {
return new Gson().toJson(this);
}
}
@Get("json")
public Representation represent() {
Foo foo = new Foo("bar");
return new JsonRepresentation(foo.toJson());
}
@Post("json")
public Representation post(Representation entity) {
JsonRepresentation json = null;
try {
json = new JsonRepresentation(entity);
Gson gson = new Gson();
Foo foo = gson.fromJson(json.getText(), Foo.class);
} catch (Exception e) {
System.err.println(e.getMessage());
}
return json;
}
发布于 2011-02-04 17:07:59
我找到了一个
博客引擎:http://code.google.com/p/blogress/
https://stackoverflow.com/questions/4529803
复制相似问题