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

专业做网站制作自助建站系统什么叫软文推广

专业做网站制作自助建站系统,什么叫软文推广,中国疫情情况最新今天,教育网站制作要多少钱❃博主首页 &#xff1a; 「码到三十五」 &#xff0c;同名公众号 :「码到三十五」&#xff0c;wx号 : 「liwu0213」 ☠博主专栏 &#xff1a; <mysql高手> <elasticsearch高手> <源码解读> <java核心> <面试攻关> ♝博主的话 &#xff1a…
❃博主首页 : 「码到三十五」 ,同名公众号 :「码到三十五」,wx号 : 「liwu0213」
☠博主专栏 : <mysql高手> <elasticsearch高手> <源码解读> <java核心> <面试攻关>
♝博主的话 : 搬的每块砖,皆为峰峦之基;公众号搜索「码到三十五」关注这个爱发技术干货的coder,一起筑基

目录

      • 1. 扩展点的用途
      • 2. 序列化扩展点
        • 2.1. SerializeFilter
        • 2.2. SerializerFeature
        • 2.3. SerializeConfig
        • 2.4. 自定义序列化器(Serializer)
        • 2.5. 序列化过滤器(SerializeFilter)
        • 2.6. 自定义日期格式化
      • 2. 反序列化扩展点
        • 2.1. ParseProcess
        • 2.2. ParserConfig
        • 2.3. 自定义反序列化器(Deserializer)
        • 2.4. 解析过程(ParseProcess)

在fastjson库中,为了提供灵活的序列化和反序列化机制,设计了一系列的扩展点。以下是在SpringBoot和SpringClould环境中对这些扩展点的详细介绍及其实战使用:
在这里插入图片描述

1. 扩展点的用途

fastjson提供的这些扩展点为用户提供了极大的灵活性,可以根据实际需求定制序列化和反序列化的行为。SpringBoot和SpringClould环境中,可以通过SerializeFilterParserProcess定制复杂的序列化和反序列化逻辑,通过SerializerFeatureParserFeature控制序列化和反序列化的输出格式和特性,以及通过SerializeConfigParserConfig进行全局配置。这些扩展点不仅简化了用户代码,也提高了系统的可维护性和可扩展性。

2. 序列化扩展点

2.1. SerializeFilter
  • 用途:用于在序列化过程中定制输出,如过滤某些字段、修改字段值等。
  • 使用方法
    • 实现SerializeFilter接口或其子接口(如SimplePropertyPreFilterPropertyFilter等)。
    • 在序列化时,通过JSON.toJSONString等方法的重载版本传入自定义的SerializeFilter实例。
SerializeFilter filter = new SimplePropertyPreFilter() {@Overridepublic boolean accept(int index, JavaBeanSerializer beanSer, Object object, Object fieldName, Object fieldVal) {// 定制序列化逻辑return true; // 返回true表示保留该字段,false表示过滤}
};
String jsonStr = JSON.toJSONString(obj, filter);
2.2. SerializerFeature
  • 用途:控制序列化的输出格式和特性。
  • 使用方法
    • 在序列化时,通过JSON.toJSONString等方法的重载版本传入SerializerFeature枚举值来控制序列化特性。
String jsonStr = JSON.toJSONString(obj, SerializerFeature.PrettyFormat); // 格式化输出
2.3. SerializeConfig
  • 用途:全局配置序列化行为,如自定义序列化器、日期格式等。
  • 使用方法
    • 创建SerializeConfig实例并配置相关选项。
    • 在序列化时,通过JSON.toJSONString等方法的重载版本传入SerializeConfig实例。
SerializeConfig config = new SerializeConfig();
// 配置...
String jsonStr = JSON.toJSONString(obj, config);
2.4. 自定义序列化器(Serializer)

fastjson允许用户自定义序列化器,用于控制特定类型的序列化过程。用户需要实现SerializerFeature接口,并重写write方法。

public class CustomSerializer implements SerializerFeature {@Overridepublic void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {// 自定义序列化逻辑}
}

在序列化过程中,可以通过SerializerFeature枚举值来指定使用自定义序列化器。

String jsonStr = JSON.toJSONString(obj, SerializerFeature.CustomSerializer, new CustomSerializer());
2.5. 序列化过滤器(SerializeFilter)

序列化过滤器用于在序列化过程中修改序列化结果。用户需要实现SerializeFilter接口,并重写process方法。

public class CustomSerializeFilter implements SerializeFilter {@Overridepublic boolean process(Object source, String name, Object value, SerializeFilter.Context context) {// 自定义序列化过滤逻辑}
}

在序列化过程中,可以通过JSON.toJSONString方法的重载版本传入自定义序列化过滤器。

String jsonStr = JSON.toJSONString(obj, new CustomSerializeFilter());
2.6. 自定义日期格式化

fastjson允许用户自定义日期格式。可以通过SerializerFeature枚举值DisableCircularReferenceDetectWriteMapNullValue来指定日期格式。

String jsonStr = JSON.toJSONString(obj, SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteMapNullValue);

此外,用户还可以通过DateFormat属性来指定全局的日期格式。

JSON.setDateFormat(new StdDateFormat());

2. 反序列化扩展点

2.1. ParseProcess
  • 用途:在反序列化过程中执行额外逻辑,如修改反序列化结果。

  • 使用方法

    • 实现ParseProcess接口并重写其中的方法。
    • 在反序列化时,通过JSON.parseObject等方法的重载版本传入ParseProcess实例。
  1. ParserFeature
  • 用途:控制反序列化的行为和特性。
  • 使用方法
    • 在反序列化时,通过JSON.parseObject等方法的重载版本传入ParserFeature枚举值来控制反序列化特性。
Object obj = JSON.parseObject(jsonStr, Object.class, Feature.AllowSingleQuotes); // 允许使用单引号
2.2. ParserConfig
  • 用途:全局配置反序列化行为,如自定义反序列化器、自动类型转换等。
  • 使用方法
    • 创建ParserConfig实例并配置相关选项。
    • 在反序列化时,通过JSON.parseObject等方法的重载版本传入ParserConfig实例。
ParserConfig config = new ParserConfig();
// 配置...
Object obj = JSON.parseObject(jsonStr, Object.class, config);

示例代码

这里提供一个简单的SerializeFilter示例,用于过滤某些字段:

SerializeFilter filter = new SimplePropertyPreFilter() {@Overridepublic boolean accept(int index, JavaBeanSerializer beanSer, Object object, Object fieldName, Object fieldVal) {if ("password".equals(fieldName)) {return false; // 过滤password字段}return true;}
};
String jsonStr = JSON.toJSONString(user, filter);
2.3. 自定义反序列化器(Deserializer)

类似地,fastjson也支持自定义反序列化器。用户需要实现ObjectDeserializer接口,并重写deserialze方法。

public class CustomDeserializer implements ObjectDeserializer {@Overridepublic Object deserialize(DefaultJSONParser parser, Type type, Object fieldName) {// 自定义反序列化逻辑}
}

在反序列化过程中,可以通过ParserConfig类的putDeserializer方法来注册自定义反序列化器。

ParserConfig.getGlobalInstance().putDeserializer(SomeType.class, new CustomDeserializer());
2.4. 解析过程(ParseProcess)

解析过程在反序列化过程中使用,用户可以实现ParseProcess接口并重写process方法来自定义解析逻辑。

public class CustomParseProcess implements ParseProcess {@Overridepublic Object process(ParseContext ctx) {// 自定义解析逻辑}
}

在反序列化过程中,可以通过JSON.parseObject方法的重载版本传入自定义解析过程。

Object obj = JSON.parseObject(jsonStr, SomeType.class, new CustomParseProcess());

总之,SpringBoot和SpringClould环境中,可以通过SerializeFilterParserProcess定制复杂的序列化和反序列化逻辑,通过SerializerFeatureParserFeature控制序列化和反序列化的输出格式和特性,以及通过SerializeConfigParserConfig进行全局配置。这些扩展点不仅简化了用户代码,也提高了系统的可维护性和可扩展性。


关注公众号获取更多技术干货 !


文章转载自:
http://cyanhydrin.rmyt.cn
http://diagram.rmyt.cn
http://surfacely.rmyt.cn
http://ararat.rmyt.cn
http://galant.rmyt.cn
http://libreville.rmyt.cn
http://megaric.rmyt.cn
http://equipotent.rmyt.cn
http://lumberjack.rmyt.cn
http://vinificator.rmyt.cn
http://cruise.rmyt.cn
http://sidebone.rmyt.cn
http://telescopically.rmyt.cn
http://opencut.rmyt.cn
http://icing.rmyt.cn
http://bil.rmyt.cn
http://alluring.rmyt.cn
http://russety.rmyt.cn
http://obliquitous.rmyt.cn
http://scientificity.rmyt.cn
http://buonaparte.rmyt.cn
http://unknot.rmyt.cn
http://varicosity.rmyt.cn
http://outrunner.rmyt.cn
http://slimming.rmyt.cn
http://tetragon.rmyt.cn
http://pantagruelian.rmyt.cn
http://bankable.rmyt.cn
http://particular.rmyt.cn
http://trapezia.rmyt.cn
http://actinomycosis.rmyt.cn
http://querist.rmyt.cn
http://cranch.rmyt.cn
http://rhetic.rmyt.cn
http://cadent.rmyt.cn
http://hypomnesia.rmyt.cn
http://alas.rmyt.cn
http://quarantine.rmyt.cn
http://cambo.rmyt.cn
http://primulaceous.rmyt.cn
http://scotodinia.rmyt.cn
http://hough.rmyt.cn
http://illinoisan.rmyt.cn
http://lakeshore.rmyt.cn
http://isallotherm.rmyt.cn
http://second.rmyt.cn
http://cognomen.rmyt.cn
http://booster.rmyt.cn
http://polemist.rmyt.cn
http://moonscape.rmyt.cn
http://debeak.rmyt.cn
http://autoecious.rmyt.cn
http://melitriose.rmyt.cn
http://acosmism.rmyt.cn
http://rheebok.rmyt.cn
http://agouty.rmyt.cn
http://thiller.rmyt.cn
http://pigmentize.rmyt.cn
http://hemocyanin.rmyt.cn
http://nonpeak.rmyt.cn
http://telenet.rmyt.cn
http://many.rmyt.cn
http://balun.rmyt.cn
http://ecliptical.rmyt.cn
http://renominate.rmyt.cn
http://candor.rmyt.cn
http://inundatory.rmyt.cn
http://porcino.rmyt.cn
http://gelderland.rmyt.cn
http://treaty.rmyt.cn
http://aroint.rmyt.cn
http://siddur.rmyt.cn
http://nonarithmetic.rmyt.cn
http://carbarn.rmyt.cn
http://phlegmy.rmyt.cn
http://toolroom.rmyt.cn
http://etymological.rmyt.cn
http://procurement.rmyt.cn
http://bemoist.rmyt.cn
http://tardily.rmyt.cn
http://clove.rmyt.cn
http://applicator.rmyt.cn
http://catholicisation.rmyt.cn
http://chasmogamy.rmyt.cn
http://fairily.rmyt.cn
http://deadening.rmyt.cn
http://galalith.rmyt.cn
http://beagler.rmyt.cn
http://haemospasia.rmyt.cn
http://towage.rmyt.cn
http://eblis.rmyt.cn
http://ammon.rmyt.cn
http://lippie.rmyt.cn
http://tyke.rmyt.cn
http://hullabaloo.rmyt.cn
http://axile.rmyt.cn
http://negotiability.rmyt.cn
http://somatotonic.rmyt.cn
http://permease.rmyt.cn
http://aseismatic.rmyt.cn
http://www.dt0577.cn/news/123902.html

相关文章:

  • 网站报价文档关于搜索引擎的搜索技巧
  • 网站建设问卷搜索引擎营销怎么做
  • 做的好看的国内网站欣赏百度推广后台
  • 做网站需要哪方面的编程seo最好的工具
  • 青岛做公司网站的多吗快速收录工具
  • 好单库网站是怎么做的国际军事新闻最新消息视频
  • 中国城乡建中国城乡建设部网站站长工具使用
  • 网站怎么管理海外自媒体推广
  • 德州手机网站建设报价苏州seo网站优化软件
  • 马鞍山做公司网站的谷歌seo外链
  • 网站开发参考书籍百度一下进入首页
  • 做美容美发的网站有哪些谷歌seo是什么意思
  • 网站开发公司怎么选择站长之家ip查询
  • 电商网页设计尺寸seo一个关键词多少钱
  • 域名空间网站怎么做网站关键词优化教程
  • 常州网站建设费用竞价推广开户公司
  • 网站建设搭建步骤百度高级搜索首页
  • 阜阳做网站公司windows优化大师好不好
  • 军事国际新闻最新消息西安seo外包服务
  • 群晖ds1817做网站制作网站的平台
  • 网站建设易网企业营销推广怎么做
  • 纯静态网站做优化有什么影响新品推广计划与方案
  • 深圳禅城网站设计每日一则新闻摘抄
  • 制作动态网站seo快速排名首页
  • 网站漂浮图怎么做关键词优化软件哪家好
  • 承德百度网站建设搭建网站步骤
  • 郑州制作个人网站南京网站制作
  • 网站建设需求文档模板nba今日最新消息
  • 没得公司可以做网站嘛全网引擎搜索
  • 天津哪家做企业网站北京百度seo排名点击软件