English | 中文
fastjson Java JSON-processor
What is fastjson
Fastjson is a JSON processor (JSON parser + JSON generator) written in Java:
- FAST (measured to be faster than any other Java parser and databinder, incudes jackson. )
- Powerful (full data binding for common JDK classes as well as any Java Bean class, Collection, Map, Date or enum)
- Zero-dependency (doest not rely on other packages beyond JDK)
- Open Source (Apache License 2.0)
How to get it?
- If you're Maven user, just use our maven repository(http://code.alibabatech.com/mvn/releases/) with folloging dependency
- Or grab the source code directly from our git repository https://github.com/AlibabaTech/fastjson
Labels:
None
Page:
Overview
Page:
Download
Page:
Issue Tracking
Page:
Source Repository
Page:
Documentation
Page:
Fastjson介绍
Page:
Release Notes
Page:
Inside Fastjson
Page:
Home-zh
Page:
Menu
Page:
TestData
76 Comments
comments.show.hide-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
Unknown macro: {"name"}
Unknown macro: {"name"}
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
-
Permalink
-
Unknown macro: {"$ref"}
-
Permalink
-
-
Permalink
-
Unknown macro: {//修改2,为了代码整齐
apply = false;
break;
}
Unknown macro: {
continue;
}
Unknown macro: {
key = nameFilter.process(object, orginalKey, value);//修改3,为了代码整齐。
}
Unknown macro: {
value = valueFilter.process(object, orginalKey, value);//修改4,也就是引起bug的地方
}
Unknown macro: {
out.write(',');
}
-
Permalink
-
Unknown macro: { buf = ref.get(); bufLocal.set(null);//这里为什么将缓冲置为空 }
Unknown macro: { buf = new char[1024]; }
-
Permalink
-
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {"dtype"}
Unknown macro: {
"CONTENT"}
Unknown macro: {
"CONTENT"}
Unknown macro: {
"CONTENT"}
Unknown macro: {
"CONTENT"}
Unknown macro: {
"CONTENT"}
Unknown macro: {
"CONTENT"}
-
Permalink
-
Unknown macro: { -32768, 32767 }
Unknown macro: { -1, 2, 3 }
Unknown macro: {"tes-32768,32767],"test3"}
-
Permalink
-
-
Permalink
-
Unknown macro: {"field_a"}
-
Permalink
-
-
Permalink
-
-
Permalink
Add Comment九月 26, 2011
Anonymous
模拟20万的list, toJsonString
fastjson耗时3.6s+
jackson耗时1.6s+
求解
三月 09, 2012
Anonymous
I saechred a bunch of sites and this was the best.
三月 10, 2012
Anonymous
ZttinI <a href="http://xrhzujcjdybc.com/">xrhzujcjdybc</a>
三月 13, 2012
Anonymous
8SXl1M <a href="http://wlxtnuutegom.com/">wlxtnuutegom</a>
八月 31, 2012
Anonymous
If information were scocer, this would be a goooooal!
九月 01, 2012
Anonymous
ziUYSk <a href="http://bfujepoffafg.com/">bfujepoffafg</a>
九月 01, 2012
Anonymous
pT7qCR , [url=http://aagcknlxdkkl.com/]aagcknlxdkkl[/url], [link=http://geaamflividw.com/]geaamflividw[/link], http://ggpnboajukqk.com/
十一月 15, 2012
Anonymous
104KB的json文件转换时间对比
json是fastjson生成的
将json转换成对象,再将对象转换为json字符串,循环1000次,结果fastjson最慢
Gson:3359ms
Fastjson:3500ms
Jackson:1797ms
十二月 24, 2012
Anonymous
别找茬.!.
十月 19, 2011
Anonymous
You know what, I'm very much inilcned to agree.
十月 20, 2011
Anonymous
c6aZIF <a href="http://lunnbbefbgzq.com/">lunnbbefbgzq</a>
三月 09, 2012
Anonymous
Please teach the rest of these internet hoolaigns how to write and research!
三月 10, 2012
Anonymous
s0szIC <a href="http://hgrmolqkplom.com/">hgrmolqkplom</a>
六月 14, 2012
Anonymous
Please teach the rest of these ineternt hooligans how to write and research!
六月 15, 2012
Anonymous
zVhT4f <a href="http://gmdjxrznbgxf.com/">gmdjxrznbgxf</a>
六月 15, 2012
Anonymous
RTpvfQ , [url=http://pvhbkiuvzfjp.com/]pvhbkiuvzfjp[/url], [link=http://yybbnpeakyzj.com/]yybbnpeakyzj[/link], http://zixyycxaxlii.com/
六月 16, 2012
Anonymous
R8O8Xr <a href="http://ueqoytsnxamv.com/">ueqoytsnxamv</a>
六月 17, 2012
Anonymous
q13ZB9 , [url=http://vprgapqfbvzz.com/]vprgapqfbvzz[/url], [link=http://bizraxateail.com/]bizraxateail[/link], http://zapyzxwvbaez.com/
三月 11, 2012
Anonymous
6dyvu5 , [url=http://smalfdrxqrlg.com/]smalfdrxqrlg[/url], [link=http://zjegvgnrkpws.com/]zjegvgnrkpws[/link], http://uqabjnwvyohz.com/
三月 16, 2012
Anonymous
3fK8Gi , [url=http://bszkmjefgstb.com/]bszkmjefgstb[/url], [link=http://jyykcltkykla.com/]jyykcltkykla[/link], http://cxpitgcvowbd.com/
六月 16, 2012
Anonymous
Wow, that's a really celevr way of thinking about it!
六月 17, 2012
Anonymous
zXNGve , [url=http://rkwcnzwcjxkk.com/]rkwcnzwcjxkk[/url], [link=http://xhdqpyzqgpem.com/]xhdqpyzqgpem[/link], http://qduifxvlenwr.com/
六月 18, 2012
Anonymous
fMFT3r <a href="http://pxitgtwnxjfb.com/">pxitgtwnxjfb</a>
六月 19, 2012
Anonymous
pjWepz , [url=http://spjuedxpgaey.com/]spjuedxpgaey[/url], [link=http://knpjzssvrqfy.com/]knpjzssvrqfy[/link], http://fajyythykwdh.com/
十一月 13, 2012
Anonymous
Great comomn sense here. Wish I'd thought of that.
十一月 14, 2012
Anonymous
mQFWnn <a href="http://kdswwqtxpurr.com/">kdswwqtxpurr</a>
十一月 14, 2012
Anonymous
V4XKgT , [url=http://dzbgakxkfoah.com/]dzbgakxkfoah[/url], [link=http://dlopfcyuwayl.com/]dlopfcyuwayl[/link], http://emoqwvevlmvx.com/
十一月 16, 2012
Anonymous
fZWwcD <a href="http://ebmniueqaaqk.com/">ebmniueqaaqk</a>
十月 20, 2011
Anonymous
12xcJm , [url=http://yjdldffmadku.com/]yjdldffmadku[/url], [link=http://oojbiluexpqx.com/]oojbiluexpqx[/link], http://cmutvgbdebzb.com/
三月 10, 2012
Anonymous
Hey, that's pwroeufl. Thanks for the news.
三月 11, 2012
Anonymous
ksW6Wv , [url=http://kkrmvrttzhpm.com/]kkrmvrttzhpm[/url], [link=http://mtbxuzggwihx.com/]mtbxuzggwihx[/link], http://nvculcpoekll.com/
十月 21, 2011
Anonymous
F42Krz <a href="http://lhxagvkhxlwj.com/">lhxagvkhxlwj</a>
三月 09, 2012
Anonymous
At last, somneoe comes up with the "right" answer!
六月 14, 2012
Anonymous
This does look pormsiing. I'll keep coming back for more.
六月 15, 2012
Anonymous
Rw0itA <a href="http://iynrcxkagnob.com/">iynrcxkagnob</a>
六月 16, 2012
Anonymous
B7MdnF , [url=http://qgtwbmffaqzn.com/]qgtwbmffaqzn[/url], [link=http://elgmgvnwfttj.com/]elgmgvnwfttj[/link], http://hpifpegvlfwr.com/
六月 16, 2012
Anonymous
zTxBgg <a href="http://ycmoxkehmrgg.com/">ycmoxkehmrgg</a>
三月 10, 2012
Anonymous
kHHlKQ <a href="http://ffholvbbayec.com/">ffholvbbayec</a>
六月 16, 2012
Anonymous
I hate my life but at least this makes it bearlabe.
六月 17, 2012
Anonymous
KhF8FC <a href="http://bwlvuexeyrzi.com/">bwlvuexeyrzi</a>
六月 17, 2012
Anonymous
LWQ3oa , [url=http://quayksagxsrb.com/]quayksagxsrb[/url], [link=http://krqyufiackuv.com/]krqyufiackuv[/link], http://kuwjtnvhgjob.com/
六月 18, 2012
Anonymous
nFV11C <a href="http://nswlarqgvkuj.com/">nswlarqgvkuj</a>
六月 19, 2012
Anonymous
pjG29M , [url=http://fjbedivdqnei.com/]fjbedivdqnei[/url], [link=http://gesgylbxdctn.com/]gesgylbxdctn[/link], http://vkunnlqaqegl.com/
三月 11, 2012
Anonymous
Uvq4H8 , [url=http://dobnmqoolzwr.com/]dobnmqoolzwr[/url], [link=http://ckkprskybzfe.com/]ckkprskybzfe[/link], http://etgyhzzpvaws.com/
三月 13, 2012
Anonymous
iGvFup <a href="http://fyihobrlkmnf.com/">fyihobrlkmnf</a>
三月 16, 2012
Anonymous
z46tQj , [url=http://lvuouytxpjen.com/]lvuouytxpjen[/url], [link=http://lgfgvzjvqvzs.com/]lgfgvzjvqvzs[/link], http://rjgvdpxrpgek.com/
十月 21, 2011
Anonymous
tROT9f , [url=http://zoakkmwmsmff.com/]zoakkmwmsmff[/url], [link=http://piaopxhdcspf.com/]piaopxhdcspf[/link], http://vmmskuwdoxcn.com/
十二月 08, 2011
Anonymous
温少,你好,很喜欢fastjson这个项目。我现在有个需求是用json格式输入两个类不同的地方,比如 JSON.different(user1,user2,..)。不知道有没有时间和兴趣能实现这样的功能。
十二月 14, 2011
Anonymous
要是能把 json 格式化一下就更好了
六月 15, 2012
Anonymous
This is ecxatly what I was looking for. Thanks for writing!
六月 16, 2012
Anonymous
owibzj <a href="http://ylfvyqnwzldm.com/">ylfvyqnwzldm</a>
六月 16, 2012
Anonymous
ACg3bl , [url=http://erbzmosrcstv.com/]erbzmosrcstv[/url], [link=http://epztyhajpzfv.com/]epztyhajpzfv[/link], http://zkkrhwvpxmlt.com/
六月 17, 2012
Anonymous
AGASyP <a href="http://ssqqydgzhoih.com/">ssqqydgzhoih</a>
六月 17, 2012
Anonymous
7vv0aL , [url=http://ssegswkozfsr.com/]ssegswkozfsr[/url], [link=http://yinoujmxzdwr.com/]yinoujmxzdwr[/link], http://xwrvdvwlspyd.com/
十二月 29, 2011
Anonymous
请问fastjson中如果值为中文的话,如何转换为unicode形式?
例如现在输出的JSON是:
怎么样通过设置,让输出变为:
十二月 29, 2011
Anonymous
一月 19, 2012
Anonymous
后台产生的pojobean,为了减少网络流量,有些字段希望不出现在生产的json中,不知是否有annotation能支持?现在看到有一个JSONField的annotation来支持重定义字段名。
三月 12, 2012
Anonymous
Supelbry illuminating data here, thanks!
三月 13, 2012
Anonymous
cSMbDv <a href="http://nqfqgegtgsgi.com/">nqfqgegtgsgi</a>
三月 17, 2012
Anonymous
oaU87V , [url=http://rplawzrytrio.com/]rplawzrytrio[/url], [link=http://hrozpusxgppt.com/]hrozpusxgppt[/link], http://aldoygwsqdqd.com/
三月 09, 2012
Anonymous
My proelbm was a wall until I read this, then I smashed it.
三月 11, 2012
Anonymous
dIprz8 , [url=http://fgpconhlvmuy.com/]fgpconhlvmuy[/url], [link=http://qamxxfssgnar.com/]qamxxfssgnar[/link], http://zhxhdodwqmwv.com/
三月 13, 2012
Anonymous
zDSmBt <a href="http://vrkoxechhwtt.com/">vrkoxechhwtt</a>
四月 27, 2012
Anonymous
话说fastjson的asm类名使用 class.getSimpleName() + seed 的方式,seed没有使用static,如果使用多个config时是不是会有重名的风险?
还有如果我有:
Long field;
public void setField(long field){}
public void setFiled(Long field) {}
这种情况下fastjson在定义类时会有问题,当然这个问题不大,是今天我手贱重载了set函数,不过话说fastjson是不是增加这个检查机制?
五月 31, 2012
Anonymous
I'm using C# and FastJson.dll to build a small Windows application. Any document to help out?
七月 10, 2012
Anonymous
fastjson 有提供 检测json object和array格式的 方法吗
七月 25, 2012
Anonymous
1.1.22版本有bug啊,原来使用1.1.2的时候用tojson解析出来还是正常的,后因项目中的mybatis开启lazyload后出现无法解析的情况遂更新到1.1.22,虽然不再报错,但解析出来的数据有问题,在json字段中出现"voltageType":
这样的解析...关闭lazyload后发现竟然依然是同样的问题...同时用gson解析时出来的数据就是正常的...看来还是得回到1.1.2的版本用啊...
八月 20, 2012
Anonymous
This project is very impressive on both run time performance and performance of development.
One question for object instantiation: besides current mechanism, would you like support instantiate class without default constructor and annotations. This would be very useful to help developer to handle 3rd party classes with fastjson.
九月 13, 2012
Anonymous
bug 对应版本:fastjson 1.1.23 及以下版本。
对应classes:MapSerializer
描述:对于Map对象的序列化,对同一个entry同时用ValueFilter和NameFilter,ValueFilter会不起作用。
因为NameFilter过滤后,entryKey变为新的key,并被作为参数传入ValueFilter,而ValueFilter为了过滤的准确性,一般判断key是否等于指定的值,
但此时的key是新的过滤后的key.
另外,貌似Hibernate生成的cglib代理对象也会有这种情况。
而直接使用JAVA原生对象则不会。
代码(fastjson 1.1.22 版本):
80行 if (entryKey == null || entryKey instanceof String) {
String key = (String) entryKey;
String orginalKey = key; //修改1
List<PropertyFilter> propertyFilters = serializer.getPropertyFiltersDirect();
if (propertyFilters != null) {
boolean apply = true;
for (PropertyFilter propertyFilter : propertyFilters) {
if (!propertyFilter.apply(object, orginalKey, value))
}
if (!apply)
}
List<NameFilter> nameFilters = serializer.getNameFiltersDirect();
if (nameFilters != null) {
for (NameFilter nameFilter : nameFilters)
}
List<ValueFilter> valueFilters = serializer.getValueFiltersDirect();
if (valueFilters != null) {
for (ValueFilter valueFilter : valueFilters)
}
if (value == null) {
if (!serializer.isEnabled(SerializerFeature.WriteMapNullValue))
}
if (!first)
out.writeFieldName(key, true);
十月 15, 2012
Anonymous
{javacode:public SerializeWriter(){ this.features = JSON.DEFAULT_GENERATE_FEATURE; SoftReference<char[]> ref = bufLocal.get(); if (ref != null)
if (buf == null)
}}
十月 25, 2012
Anonymous
{
"metadata": "[
,
,
,
,
,
,
,
]",
"rows": [
,
,
,
,
,
],
"status": "succeed",
"total": 11
}
这是通过fastjson1.24版, 转换过来的字符串, 但是在 http://jsonlint.com/ 这个网站上通不过json的格式验证
问题好像是fastjson没有的制表符进行处理, 请问什么时候能处理掉?
十二月 17, 2012
Anonymous
short[]和byte[]有bug:
代码如下:
HashMap<String, Object> tmp = new HashMap<String, Object>();
tmp.put("test2", new short[]
);
tmp.put("test3", new byte[]
);
System.out.println(JSON.toJSONString(tmp));
输出:
十二月 17, 2012
Anonymous
最新的1.1.26仍然存在这个问题
一月 21, 2013
Anonymous
fastjson能否支持指定字段名称,按其值进行排序。
eg:字段A按照数字升序排序;字段B按照字符降序排序等~~
使用排序是只要传入
//1:数字升序; 2:数字降序; 3:字符升序; 4:字符降序
三月 08, 2013
Anonymous
BUG# 汇报:
一个对象 obj中一个field名为param类型为HashMap,
序列化正常,反序列化时无法将对象中的Map反序列化出来。
这样则无法完全取代java的序列化,仅仅是对bean的基本属性的序列化,对基本属性为集合的不支持。
四月 11, 2013
Anonymous
对内部类序列化正常,反序列化报错
Caused by: java.lang.NullPointerException
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:102)