Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

ReuseObject_cn

高铁 edited this page Feb 11, 2017 · 1 revision
public static class Model {
    public int id;
    public String name;
}

Model model = new Model();

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":123,\"name\":\"wangsai-silence\"}");
    parser.parseObject(model);
    parser.close(); // 调用close能重用buf,提升性能

    assertEquals(123, model.id);
    assertEquals("wangsai-silence", model.name);
}

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":234,\"name\":\"wenshao\"}");
    parser.parseObject(model);
    parser.close(); // 调用close能重用buf,提升性能

    assertEquals(234, model.id);
    assertEquals("wenshao", model.name);
}
Clone this wiki locally