2

GAEでホストされているRestletのオープンソースプロジェクトを探しており、restlet + objectifyでCRUD操作を理解しようとしています。現在のアプリケーションでは、次のように使用しています。

  • 残りの完全な Web サービスに Restlet を使用する
  • ORM フレームワークとしてオブジェクト化します。
  • GAE でホストされています。

restlet で JSON 表現を使用して応答を要求する方法については、あまり明確ではありません。

そのため、Google コードまたは github で進行中のオープン ソース プロジェクトがあれば、それは役に立ちます。

ありがとう

4

2 に答える 2

1

プロジェクトで同じテクノロジーを使用しています。JSON 表現の例を探している場合は、以下のコードが役立つ場合があります。JSONのシリアライゼーション/デシリアライゼーションを処理するためにGsonを使用しています:

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-01-27T22:05:41.267 に答える
0

私はそれを見つけました

ブログ エンジン: http://code.google.com/p/bloggress/

于 2011-02-04T17:07:59.943 に答える