Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Resolve bug of FastJson 1.2.39

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. The default format of date conversion overrides the bug of the annotation format.

Com.alibaba.fastjson.serializer.JSONSerializer#writeWithFormat

The modified code:

Public final void writeWithFormat (Object object, String format) {if (object instanceof Date) {DateFormat dateFormat = this.getDateFormat (); if (formatting null) {dateFormat = new SimpleDateFormat (format, locale); dateFormat.setTimeZone (timeZone);} String text = dateFormat.format ((Date) object); out.writeString (text); return;} write (object);}

2. Fixed the problem that the Bean field is sorted by default when transferring to JSON:

Com.alibaba.fastjson.serializer.SerializeWriter#computeFeatures

Modified code:

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?'\':'";}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report