This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
JSONField_format_gzip
高铁 edited this page Jun 11, 2017
·
1 revision
在1.2.33版本中,JSONField.format增加了对gzip压缩的支持,当用json传输较大的byte[]时可以启用减少网络传输。
public static class Model {
@JSONField(format = "gzip")
public byte[] value;
}
Model model = new Model();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < 1000; ++i) {
buf.append("0123456890");
buf.append("ABCDEFGHIJ");
}
model.value = buf.toString().getBytes();
String json = JSON.toJSONString(model);
assertEquals("{\"value\":\"H4sIAAAAAAAAAO3IsRGAIBAAsJVeUE5LBBXcfyC3sErKxJLyupX9iHq2ft3PmG8455xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555xzzjnnnHPOOeecc84555z7/T6powiAIE4AAA==\"}", json);
Model model1 = JSON.parseObject(json, Model.class);
Assert.assertArrayEquals(model.value, model1.value);
如有需要修改本注脚,请联系阿里巴巴,
© Alibaba Fastjson Develop Team
注明: 版权所有阿里巴巴,请注明版权所有者
If you need to amend this footnote, please contact Alibaba.
© Alibaba Fastjson Develop Team
Note: Copyright Alibaba, please indicate the copyright owner