1、日期转换默认格式覆盖注解格式的bug;
创新互联成立与2013年,是专业互联网技术服务公司,拥有项目成都网站建设、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元南丹做网站,已为上家服务,为南丹各地企业和个人服务,联系电话:18982081108
com.alibaba.fastjson.serializer.JSONSerializer#writeWithFormat
修改后的代码:
public final void writeWithFormat(Object object, String format) { if (object instanceof Date) { DateFormat dateFormat = this.getDateFormat(); if(format!=null){ dateFormat = new SimpleDateFormat(format, locale); dateFormat.setTimeZone(timeZone); } String text = dateFormat.format((Date) object); out.writeString(text); return; } write(object); }
2、解决转JSON时候Bean字段默认被排序的毛病:
com.alibaba.fastjson.serializer.SerializeWriter#computeFeatures
修改的代码:
protected void computeFeatures() { quoteFieldNames = (this.features & SerializerFeature.QuoteFieldNames.mask) != 0; useSingleQuotes = (this.features & SerializerFeature.UseSingleQuotes.mask) != 0; // sortField = (this.features & SerializerFeature.SortField.mask) != 0; sortField = false; disableCircularReferenceDetect = (this.features & SerializerFeature.DisableCircularReferenceDetect.mask) != 0; beanToArray = (this.features & SerializerFeature.BeanToArray.mask) != 0; writeNonStringValueAsString = (this.features & SerializerFeature.WriteNonStringValueAsString.mask) != 0; notWriteDefaultValue = (this.features & SerializerFeature.NotWriteDefaultValue.mask) != 0; writeEnumUsingName = (this.features & SerializerFeature.WriteEnumUsingName.mask) != 0; writeEnumUsingToString = (this.features & SerializerFeature.WriteEnumUsingToString.mask) != 0; writeDirect = quoteFieldNames // && (this.features & nonDirectFeautres) == 0 // && (beanToArray || writeEnumUsingName) ; keySeperator = useSingleQuotes ? '\'' : '"'; }
网站标题:解决FastJson1.2.39的bug
文章路径:https://www.cdcxhl.com/article14/iiicde.html
成都网站建设公司_创新互联,为您提供关键词优化、微信公众号、营销型网站建设、品牌网站建设、移动网站建设、App设计
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联