我正在寻找在GAE上托管的Restlet的开源项目,并试图通过restlet + objectify找出CRUD操作。在我目前的应用程序中,我使用了以下,
我不太清楚如何在restlet中请求JSON表示的响应。
因此,如果谷歌代码或github上有开源项目,那将有所帮助。
由于
答案 0 :(得分:1)
我在项目中使用相同的技术。如果您正在寻找JSON表示示例,下面的代码可能会有所帮助。我正在使用Gson来处理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;
}
答案 1 :(得分:0)
我找到了一个