GeekFactory

int128.hatenablog.com

Jsonizer

Google App Engineに最適化したJSONライブラリを作っています。依存クラスが少なく、リフレクションを使わないので、高いパフォーマンスが期待できます。

使い方はこんな感じ。

public class EventlogController extends Controller
{
  @Override
  public Navigation run() throws Exception
  {
    Jsonizer.type(Event.class, new PropertyGetter<Event>() {
        public void get(Event m) {
          property("url", m.getRequestUrl());
          property("time", m.getRequestDate().getTime());
          property("code", m.getResponseCode());
          property("responseTime", m.getResponseTime());
        }
      })
      .jsonize(new EventService().getEvents(asKey("k")))
      .send(response);
    
    return null;
  }
}

モデルから必要な属性をピックアップし、プロパティに格納するという流れを想定しています。

必要なクラスはたった4つです。続きはgithubで。

今日は #ahack6 に初参加の予定でしたが、残念ながら仕事で行けず><