新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

解决FastJson1.2.39的bug-创新互联

1、日期转换默认格式覆盖注解格式的bug;

创新互联公司服务项目包括鹤岗网站建设、鹤岗网站制作、鹤岗网页制作以及鹤岗网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,鹤岗网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到鹤岗省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前标题:解决FastJson1.2.39的bug-创新互联
本文路径:http://www.wjwzjz.com/article/dcgogd.html
在线咨询
服务热线
服务热线:028-86922220
TOP