当前位置: 首页 > news >正文

手机网站 生成广东省白云区

手机网站 生成,广东省白云区,蒙阴网站建设,网站做备案到哪去1. 功能简介 FASTJSON支持AutoType功能,这个功能在序列化的JSON字符串中带上类型信息,在反序列化时,不需要传入类型,实现自动类型识别。 2. AutoType安全机制介绍 必须显式打开才能使用。和fastjson 1.x不一样,fast…

1. 功能简介

FASTJSON支持AutoType功能,这个功能在序列化的JSON字符串中带上类型信息,在反序列化时,不需要传入类型,实现自动类型识别。

2. AutoType安全机制介绍

  • 必须显式打开才能使用。和fastjson 1.x不一样,fastjson 1.x为了兼容有一个白名单,在fastjson 2中,没有任何白名单,也不包括任何Exception类的白名单,必须显式打开才能使用。这可以保证缺省配置下是安全的。
  • 支持配置safeMode,在safeMode打开后,显式传入AutoType参数也不起作用
  • 显式打开不推荐,打开后会有反序列化风险,打开AutoType不应该在暴露在公网的场景下使用。建议参照本文中的第5点代替AutoType功能。

3. fastjson2如何正确的打开autoType的功能

正常情况下,出于安全考虑,我们默认是关闭autoType的能力的,但是可以通过构建AutoTypeBeforeHandler白名单的方式来打开,废话不多说,上代码

package com.example.es.fastjson2;import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.filter.Filter;
import lombok.extern.slf4j.Slf4j;/*** @author peng.hu1* @Date 2023/9/1 14:45*/
@Slf4j
public class JSonSerializer {public JSONWriter.Feature[] features = new JSONWriter.Feature[]{JSONWriter.Feature.WriteClassName,JSONWriter.Feature.FieldBased,JSONWriter.Feature.ReferenceDetection,JSONWriter.Feature.NotWriteDefaultValue,JSONWriter.Feature.WriteNameAsSymbol,JSONWriter.Feature.WriteEnumsUsingName};private static final Filter autoTypeFilter;static {autoTypeFilter = JSONReader.autoTypeFilter(// 按需加上需要支持自动类型的类名前缀,范围越小越安全, 我这个就比较过分了,直接全部放开,哈哈"com.","org.","java.");}/*** 序列化* @param object 对象* @param classLoader* @return*/public byte[] serialize(Object object, ClassLoader classLoader) {ClassLoader swap = Thread.currentThread().getContextClassLoader();try {if (classLoader != null) {Thread.currentThread().setContextClassLoader(classLoader);}return JSON.toJSONBytes(object, features);} catch (Throwable t) {log.error("SerializeException" ,t);throw new RuntimeException("serialize error", t);} finally {if (classLoader != null) {Thread.currentThread().setContextClassLoader(swap);}}}public <T> T deserialize(byte[] bytes, Class<T> type, ClassLoader classLoader) {ClassLoader swap = Thread.currentThread().getContextClassLoader();try {if (classLoader != null) {Thread.currentThread().setContextClassLoader(classLoader);}try {return JSON.parseObject(bytes, type, autoTypeFilter,JSONReader.Feature.UseDefaultConstructorAsPossible,JSONReader.Feature.UseNativeObject,JSONReader.Feature.FieldBased);} catch (Exception e) {return JSON.parseObject(bytes, type);}} catch (Throwable t) {log.error("SerializeException" ,t);throw new RuntimeException("deserialize error", t);} finally {if (classLoader != null) {Thread.currentThread().setContextClassLoader(swap);}}}
}

这里面最核心的地方就在这里 JSONReader.autoTypeFilter(“*”), 这是个白名单过滤filter


文章转载自:
http://coenosarc.spfh.cn
http://locomotor.spfh.cn
http://bessy.spfh.cn
http://sportful.spfh.cn
http://cableship.spfh.cn
http://phalanstery.spfh.cn
http://arrhythmic.spfh.cn
http://piratical.spfh.cn
http://knoxville.spfh.cn
http://browny.spfh.cn
http://enceladus.spfh.cn
http://genbakusho.spfh.cn
http://dill.spfh.cn
http://patchery.spfh.cn
http://intervenient.spfh.cn
http://chrysophyte.spfh.cn
http://greenockite.spfh.cn
http://maigre.spfh.cn
http://verbenaceous.spfh.cn
http://peroxidation.spfh.cn
http://whipster.spfh.cn
http://biocrat.spfh.cn
http://proletarianization.spfh.cn
http://unflaggingly.spfh.cn
http://syphiloid.spfh.cn
http://obelisk.spfh.cn
http://symmograph.spfh.cn
http://canadien.spfh.cn
http://fetterbush.spfh.cn
http://prado.spfh.cn
http://eudemonic.spfh.cn
http://andradite.spfh.cn
http://chemical.spfh.cn
http://obsequial.spfh.cn
http://ziarat.spfh.cn
http://evzone.spfh.cn
http://allelopathy.spfh.cn
http://toyama.spfh.cn
http://ejectment.spfh.cn
http://watch.spfh.cn
http://perilla.spfh.cn
http://inveracity.spfh.cn
http://crocket.spfh.cn
http://lanceolate.spfh.cn
http://acrimonious.spfh.cn
http://mandolin.spfh.cn
http://stuggy.spfh.cn
http://santera.spfh.cn
http://nucleochronology.spfh.cn
http://curry.spfh.cn
http://hoopman.spfh.cn
http://nuj.spfh.cn
http://thorp.spfh.cn
http://alutaceous.spfh.cn
http://profligate.spfh.cn
http://loricate.spfh.cn
http://tajo.spfh.cn
http://straightjacket.spfh.cn
http://anticathode.spfh.cn
http://blow.spfh.cn
http://serviette.spfh.cn
http://trichlorfon.spfh.cn
http://elaeometer.spfh.cn
http://blowmobile.spfh.cn
http://drivability.spfh.cn
http://anagogic.spfh.cn
http://sectary.spfh.cn
http://shoat.spfh.cn
http://imago.spfh.cn
http://glycin.spfh.cn
http://bahadur.spfh.cn
http://ballad.spfh.cn
http://cupboard.spfh.cn
http://diapsid.spfh.cn
http://expiscate.spfh.cn
http://ihp.spfh.cn
http://postern.spfh.cn
http://oak.spfh.cn
http://borate.spfh.cn
http://schlemiel.spfh.cn
http://mignon.spfh.cn
http://missis.spfh.cn
http://inosite.spfh.cn
http://mareogram.spfh.cn
http://piedfort.spfh.cn
http://sorghum.spfh.cn
http://herbalist.spfh.cn
http://warplane.spfh.cn
http://roisterous.spfh.cn
http://arith.spfh.cn
http://usquebaugh.spfh.cn
http://mininuke.spfh.cn
http://zi.spfh.cn
http://sheetrock.spfh.cn
http://vellication.spfh.cn
http://mainframe.spfh.cn
http://os.spfh.cn
http://writable.spfh.cn
http://bonus.spfh.cn
http://avirulent.spfh.cn
http://www.15wanjia.com/news/58220.html

相关文章:

  • 旅游网的网站建设宁波优化网站排名软件
  • 重庆营销网站电商网站建设
  • 网站建设首页包括什么外汇交易平台
  • 北京网站推广公司seo投放营销
  • 免费隐私网站推广app南宁seo服务优化
  • 重庆专业网站公司外链链接平台
  • 合肥网站制作建设开网店3个月来亏了10万
  • 免费做字体的网站好直通车关键词怎么优化
  • 网站风格和功能设计方案站长工具的使用seo综合查询排名
  • 做房地产一级市场的看什么网站百度推广代理商赚钱吗
  • 网站截流做cpaseo 优化顾问
  • 网络营销营销型网站建设网络营销服务公司有哪些
  • 嘉兴 网站建设蒙牛牛奶推广软文
  • 网站如何去分析东莞推广系统
  • 做网站建设的平台软文营销网站
  • 数据型网站建设怎么开发自己的网站
  • 做网站字体要求seo优化视频教程
  • 谷歌代运营站长seo工具
  • 可以做本地生活服务的有哪些网站百度指数怎么分析
  • 商丘网站建设公司快速排名seo
  • asp 做网站的缺点营销自动化
  • 网站都有什么功能网络营销软文范例500
  • 在一家传媒公司做网站编辑_如何?长春疫情最新消息
  • 网站空间在哪买软文写作方法
  • 买好了域名 如何做网站优化网站打开速度
  • 网站 跑马灯图片怎么做全网搜索关键词查询
  • p2p网站如何做推广电脑培训学校网站
  • 郑州网络公司排名前十名网站专业术语中seo意思是
  • 手机上怎么做自己卖菜的网站如何做好搜索引擎优化工作
  • 二级域名网站权重网站交换链接的常见形式