Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Resolve bug of FastJson 1.2.39

Shulou Source: shulou.com Published: 2022-06-03 03:13:51 09月25日 Update

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

Tags: Code format field date time defect comment sort Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology Redmi NVidia MySQL