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

有没有专业做steam创客的网站两个wordpress联通

有没有专业做steam创客的网站,两个wordpress联通,阿里云做外贸网站,网站设计过程介绍1.什么是fastjson2#xff1f; fastjson2是阿里巴巴开发的一个高性能的Java JSON处理库#xff0c;它支持将Java对象转换成JSON格式#xff0c;同时也支持将JSON字符串解析成Java对象。本文将介绍fastjson2的常见用法#xff0c;包括JSON对象、JSON数组的创建、取值、遍历…1.什么是fastjson2 fastjson2是阿里巴巴开发的一个高性能的Java JSON处理库它支持将Java对象转换成JSON格式同时也支持将JSON字符串解析成Java对象。本文将介绍fastjson2的常见用法包括JSON对象、JSON数组的创建、取值、遍历以及与字符串、Java对象、Map、List的相互转换。 支持JSON/JSONB两种协议JSONPath 是一等公民。支持全量解析和部分解析。支持Java服务端、客户端Android、大数据场景。支持Kotlin支持JSON Schema FASTJSON v2 JSONSchema的支持 | fastjson2支持Android支持Graal Native-Image 2.代码工程 实验目标 在 Spring Web MVC 中集成 Fastjson2 pom.xml ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringboot-demo/artifactIdgroupIdcom.et/groupIdversion1.0-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdfastjson2/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-autoconfigure/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdcom.alibaba.fastjson2/groupIdartifactIdfastjson2/artifactIdversion2.0.40/version/dependencydependencygroupIdcom.alibaba.fastjson2/groupIdartifactIdfastjson2-extension-spring5/artifactIdversion2.0.40/version/dependency/dependencies /project config 使用 FastJsonHttpMessageConverter 来替换 Spring MVC 默认的 HttpMessageConverter 以提高 RestController、ResponseBody 和 RequestBody 注解的 JSON 序列化和反序列化速度。 配置示例如下 package com.et.fastjson2.config;import com.alibaba.fastjson2.JSONReader; import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.support.config.FastJsonConfig; import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List;Configuration public class WebMvcConfig implements WebMvcConfigurer {Overridepublic void configureMessageConverters(ListHttpMessageConverter? converters) {FastJsonHttpMessageConverter converter new FastJsonHttpMessageConverter();//custom configurationFastJsonConfig config new FastJsonConfig();config.setDateFormat(yyyy-MM-dd HH:mm:ss);config.setReaderFeatures(JSONReader.Feature.FieldBased, JSONReader.Feature.SupportArrayToBean);config.setWriterFeatures(JSONWriter.Feature.WriteMapNullValue, JSONWriter.Feature.PrettyFormat);converter.setFastJsonConfig(config);converter.setDefaultCharset(StandardCharsets.UTF_8);converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));converters.add(0, converter);}} controller package com.et.fastjson2.controller;import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.HashMap; import java.util.Map;RestController public class HelloWorldController {RequestMapping(/hello)public MapString, Object showHelloWorld(){MapString, Object map new HashMap();map.put(msg, HelloWorld);return map;} } 以上只是一些关键代码所有代码请参见下面代码仓库 代码仓库 https://github.com/Harries/springboot-demo 3.测试 启动spring boot工程访问http://127.0.0.1:8088/hello返回美化的Json格式说明生效了 4.fastjosn避坑 1.BigDecimal精度丢失问题 Testpublic void toJSONString() throws ParseException {UserDTO user new UserDTO();BigDecimal money new BigDecimal(-40090.07d);money money.setScale(4, RoundingMode.HALF_UP);user.setMoney(money);String createtime 2024-07-03 09:03:26.968;SimpleDateFormat format new SimpleDateFormat(yyyy-MM-dd HH:mm:ss.SSS);Date date format.parse(createtime);user.setCreateTime(date);ListUserDTO list new ArrayList();list.add(user);String jsonJSON.toJSONString(list);System.out.println(json);}} 执行结果 [{createTime:2024-07-03,money:-40090.700}] 发现没有一个怪异现象-40090.07 变成了-40090.700直接查几毛钱原因是fastjson处理bigdecimal不是吧它当成字符串处理导致丢失精度 解决方法 String jsonJSON.toJSONString(list, JSONWriter.Feature.WriteBigDecimalAsPlain); 2.日期解析问题 Test public void parseArray() {String json[{\create_time\:\2024-07-03 09:03:26.968\,\money\:-40090.0700}];System.out.println(json);ListUserDTO list1 JSON.parseArray(json, UserDTO.class,JSONReader.Feature.SupportSmartMatch);System.out.println(); } 运行结果 java.time.format.DateTimeParseException: Text 2024-07-03 09:03:26.968 could not be parsed, unparsed text found at index 10 解决方法 UserDTO上加上JSONField(format yyyy-MM-dd HH:mm:ss) 5.引用 JSONB格式文档 https://alibaba.github.io/fastjson2/jsonb_format_cnFASTJSON v2性能有了很大提升具体性能数据看这里
http://www.dnsts.com.cn/news/62945.html

相关文章:

  • 浙江省住房与城乡建设部网站网店网络营销策划方案
  • 异构国际设计公司网站网页版微信二维码登录
  • 公司网站开发交接注意事项威海网站优化公司
  • 模板网站没有源代码物联网的含义
  • 斐讯路由器做网站映射内丘企业做网站
  • 三水区网站建设不用实名认证的好玩游戏
  • 北京网站 百度快照潍坊昌大建设集团网站
  • 网站过期会怎样解决东莞经济贸易学校网络营销
  • 网站建设app开发公司开发一款app软件需要学什么
  • 网站打不开建设中哪的问题家庭优化大师免费下载
  • 重钢建设公司官方网站玉树网站建设
  • wordpress 嵌入 php代码外贸推广seo招聘
  • 把做的网站发布打万维网上山东网站建设网
  • 山东网站备案注销湖南网站seo公司
  • 做网页建网站挣钱国家鼓励做网站的行业
  • 用word怎么做首页网站SEO网站布局优化
  • 找建网站公司oppo应用商店官网
  • 建设机械网站机构酒店机票最便宜的网站建设
  • 基于php技术的个人网站设计wordpress极验证登录
  • 湖南网站建设网络公司温州网络推广平台建设
  • 浦东网站建设外贸营销网站建设
  • 哪些公司的网站做的很好微信公众号网站怎么做
  • 网站建设与管理好学吗网页设计图片超链接
  • 设计网站猪八戒高大上的企业网站
  • 网站维护和建设实报告珠海哪里有网站建设
  • 企业档案网站建设国外视觉差网站
  • html网站开发实用技术搜索引擎外部优化有哪些渠道
  • 湛江市网站建设网站建设ui设计
  • 淘宝网站建设模板免费下载海南网站建设服务
  • ups国际快递网站建设国外网站 dns