fastjson发布1.1.3版本

本博客详细介绍了Fastjson 1.1.3版本的重要更新,包括支持循环引用、自省、非缺省构造函数和工厂方法构造对象等关键功能,并提供了如何获取和使用的指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Fastjson 1.1.3是一个重要的功能增强版本,在这个版本开始,fastjson支持循环引用,完善支持WriteClassName的特性,使得fastjson开始具备替换hessian和java serialize的能力。


[b]支持循环引用。[/b]

很多用户在初次使用fastjson时都遇到了循环引用的问题,这是反映最多的问题,我越来越认识到支持循环引用的必要性。经过测试,加入循环应用的支持对性能的影响很小,小于5%。我决定在1.1.3加入循环应用支持,而且是缺省打开这个特性。

fastjson支持的循环应用是自然的,不需要象jackson那样,需要Annotation设置。fastjson支持的引用,是基于path的,方便javascript解析。

语法
{"$ref":"$"} // 引用根对象
{"$ref":"$"} // 引用根对象
{"$ref":"@"} // 引用自己
{"$ref":".."} // 引用父对象
{"$ref":"../.."} // 引用父对象的父对象
{"$ref":"$.members[0].reportTo"} // 基于路径的引用


具体例子看这里:http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=5832796


[b]自省支持[/b]
在标准中,将对象序列化为JSON文本之后,就丢失了类型信息。虽然fastjson能够支持parse时传入Class来实现类型的识别,但是这个有局限性,在fastjson 1.1.3之后,完善支持一个特性,就是自省。

具体例子请看这里:http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=5832803

[b]支持非缺省构造函数和工厂方法构造对象[/b]
fastjson 1.1.3开始支持没有缺省构造函数的Java对象的反序列化。通过@JSONCreator来标识构造对象的方式。

具体请看这里:
* 非缺省构造函数 http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=5832818
* 工厂方法 http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=5832821

[b]原型接口[/b]
以接口的方式来操作json数据,这个特性是借鉴了jackson的功能。
具体例子看这里:http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=5832824

[b]How to get it?[/b]
If you're Maven user, just use our maven repository(http://code.alibabatech.com/mvn/releases/) with folloging dependency

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.1.3</version>
</dependency>


[b]Downlaods[/b]
Binary : http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.3/fastjson-1.1.3.jar
Source :http://code.alibabatech.com/mvn/releases/com/alibaba/fastjson/1.1.3/fastjson-1.1.3-sources.jar
Subversion : http://code.alibabatech.com/svn/fastjson/trunk/fastjson/

[b]Issue tracking[/b]
http://code.alibabatech.com/jira/plugins/servlet/project-config/FASTJSON/versions
* Bug
[FASTJSON-73] - 不支持Set类型数据的反序列
[FASTJSON-77] - JSONSerializerMap存在兼容问题
[FASTJSON-78] - java.util.concurrent.TimeUnit序列化数据不对

* Improvement
[FASTJSON-71] - 使用Base64编码优化byte[]字段的序列化和反序列化性能
[FASTJSON-72] - 使用SoftReference处理ThreadLocalCache

* New Feature
[FASTJSON-74] - 支持序列化时输出类型信息
[FASTJSON-75] - 支持Key类型不是String的Map的序列化和反序列化
[FASTJSON-80] - 原型接口
[FASTJSON-81] - 支持循环引用
apply plugin: &#39;com.android.application&#39; android { compileSdkVersion 34 defaultConfig { applicationId "com.cheaperp.ec" minSdkVersion 21 targetSdkVersion 34 versionCode 7 versionName "7.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(&#39;proguard-android-optimize.txt&#39;), &#39;proguard-rules.pro&#39; } } } dependencies { implementation &#39;androidx.appcompat:appcompat:1.0.2&#39; implementation &#39;androidx.constraintlayout:constraintlayout:1.1.3&#39; testImplementation &#39;junit:junit:4.12&#39; androidTestImplementation &#39;androidx.test.ext:junit:1.1.0&#39; androidTestImplementation &#39;androidx.test.espresso:espresso-core:3.1.1&#39; implementation &#39;de.hdodenhof:circleimageview:3.0.0&#39; // 圓形 ImageView implementation &#39;com.sdsmdg.tastytoast:tastytoast:0.1.1&#39; // 帶有花樣的 Toast implementation &#39;com.squareup.okhttp3:okhttp:4.2.2&#39; // OkHttp 網路功能 implementation &#39;com.zhy:okhttputils:2.6.2&#39; // OkHttp 工具封裝 // 圖片加載(使用 Glide 最新版本 4.10.0) implementation &#39;com.github.bumptech.glide:glide:4.10.0&#39; annotationProcessor &#39;com.github.bumptech.glide:compiler:4.10.0&#39; implementation &#39;jp.wasabeef:glide-transformations:4.1.0&#39; // 毛玻璃效果 implementation &#39;com.squareup.picasso:picasso:2.8&#39; // 另一個圖片加載器(如需) // 權限申請 implementation &#39;com.yanzhenjie:permission:2.0.3&#39; // UI 元件 implementation &#39;com.android.support:design:28.0.0&#39; // ⚠️ 注意:這裡的 support:design 30.0.0 **是錯的**,應該避免與 androidx 同時使用 // 建議改用 androidx 版本或刪除此行 implementation &#39;com.youth.banner:banner:1.4.10&#39; // Banner 輪播 implementation &#39;com.github.Shashank02051997:FancyAboutPage-Android:2.6&#39; // 關於頁面 // JSON 處理(保留一個版本) implementation &#39;com.google.code.gson:gson:2.8.6&#39; // 最新穩定版,移除 2.7 // fastjson(如確實需要) implementation &#39;com.alibaba:fastjson:1.2.70&#39; // RecyclerView 及輔助 implementation &#39;androidx.recyclerview:recyclerview:1.1.0&#39; implementation &#39;com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46&#39; // 保留最新版本,移除 2.9.22 // PickerView(三級聯動) ⚠️ 請只保留一個版本 implementation &#39;com.contrarywind:Android-PickerView:4.1.8&#39; // 保留較新版本 // EventBus implementation &#39;org.greenrobot:eventbus:3.1.1&#39; // 下拉刷新 implementation &#39;com.scwang.smartrefresh:SmartRefreshLayout:1.1.0-alpha-14&#39; implementation &#39;com.scwang.smartrefresh:SmartRefreshHeader:1.1.0-alpha-14&#39; // 外部 JAR } 「功能異常」政策:違反「功能異常」政策
最新发布
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值