java解析json复杂数据的两种思路

news2024/9/23 15:33:37

文章目录

  • 一、原始需求
  • 二、简单分析
  • 三、具体实现一
    • 1. api接口
    • 2. 接口返回
    • 3. json 数据解析
      • 1.)引入Jackson库
      • 2.)定义实体
      • 3.)解析json字符串
      • 4.)运行结果
    • 4. 过程分析
  • 四、具体实现二
    • 1. 核心代码
    • 2.运行结果
  • 五、方案比较
  • 六、源码传送

一、原始需求

萌新小明最近新开了CSDN博客,蠢蠢欲动,迫不及待的发表了几篇工作中积累下来的解决问题的涂鸦之作,看着访问量慢慢涨起来,心中暗暗窃喜。现在小明想每天23点记录一下每篇文章的访问量

二、简单分析

对照需求,可以简单分解为如下步骤:

  1. 每天23点自动运行任务,实现方式:@Scheduled、cron表达式
  2. 获取每篇文章的访问量,实现方式:api接口、数据解析
  3. 记录每篇文章的访问量,实现方式:javaBean、JDBC、ORM框架

三、具体实现一

步骤1、3代码实现比较常见,不再详细描述具体实现。
下面我们详细描述步骤2的具体实现

1. api接口

接口地址: https://blog.csdn.net/community/home-api/v1/get-business-list?page={页号}&size={当前页数据条数}&businessType=blog&username={用户名}

2. 接口返回

以下面的接口为例:
https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313

返回数据如下:

{
	"code": 200,
	"message": "success",
	"traceId": "5a64396a-caf3-49ad-a6db-022c55660b75",
	"data": {
		"list": [
			{
				"articleId": 135244727,
				"title": "java lambda表达式训练题一",
				"description": "Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。使用 Lambda 表达式可以使代码变的更加简洁紧凑。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135244727",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1019,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135244727",
				"postTime": "2023-12-27 18:07:30",
				"diggCount": 7,
				"formatTime": "2023.12.27",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/d59c68b950754e879914b5319cd1b53f.png"
				],
				"collectCount": 8
			},
			{
				"articleId": 135173565,
				"title": "二维码初体验 com.google.zxing 实现续 - web api封装",
				"description": "在 二维码初体验 com.google.zxing 实现 我们实现了二维码的生成,但是大部分情况下,二维码的相关功能是作为API接口来提供服务的。我们下面便演示在springboot、Knife4j下封装api接口来实现二维码生成功能。如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135173565",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1693,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135173565",
				"postTime": "2023-12-23 20:17:11",
				"diggCount": 23,
				"formatTime": "2023.12.23",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/f0c994ca789a495a8c8c03d86d626f24.jpeg"
				],
				"collectCount": 23
			},
			{
				"articleId": 135167613,
				"title": "二维码初体验 com.google.zxing 实现",
				"description": "Java 操作二维码的开源项目很多,如 SwetakeQRCode、BarCode4j、Zxing 等,这边以Zxing 为例进行介绍。选择需要生成QR原始文件,支持 “清除空白行及空格” 以减少二维码图片大小。支持输入文本内容,直接生成二维码代码结构QrCodeUI: 完整版本代码SimpleQrCodeUI:简化版本代码如何使用下面的备份文件恢复成原始的项目代码,请移步查阅:神奇代码恢复工具-over-",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135167613",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1081,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135167613",
				"postTime": "2023-12-23 13:52:23",
				"diggCount": 6,
				"formatTime": "2023.12.23",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/d3eeac85857543869dce8967c570bdc4.jpeg"
				],
				"collectCount": 11
			},
			{
				"articleId": 135135799,
				"title": "【随笔】MD5加密字符串、文件apache、springframework实现",
				"description": "【代码】【随笔】MD5加密字符串、文件commons-codec、springframework实现。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135135799",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1507,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135135799",
				"postTime": "2023-12-21 17:29:54",
				"diggCount": 9,
				"formatTime": "2023.12.21",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/dc26b7f1c731494f80c8c3b3badfa95d.jpeg"
				],
				"collectCount": 9
			},
			{
				"articleId": 135087188,
				"title": "【随笔】java工程中JSON 字符串格式化输出",
				"description": "json字符串格式化输出fastjson、gson、jackson实现。",
				"url": "https://blog.csdn.net/qq_16127313/article/details/135087188",
				"type": 1,
				"top": false,
				"forcePlan": false,
				"viewCount": 1198,
				"commentCount": 0,
				"editUrl": "https://editor.csdn.net/md?articleId=135087188",
				"postTime": "2023-12-19 17:07:40",
				"diggCount": 8,
				"formatTime": "2023.12.19",
				"picList": [
					"https://img-blog.csdnimg.cn/direct/058249a1749e4ff5b62e1fcabf516c37.png"
				],
				"collectCount": 6
			}
		],
		"total": 71
	}
} 

3. json 数据解析

在Java中,可以使用多种库来解析JSON数据。其中最常用的是fastjson、gson和jackson。
这边我们以jackson为例来说明。

1.)引入Jackson库

<dependency>  
   <groupId>com.fasterxml.jackson.core</groupId>  
   <artifactId>jackson-databind</artifactId>  
   <version>2.13.0</version>  
</dependency>

2.)定义实体

注意这边实体属性一定要跟json数据字段key对应,否则会解析报错

@Data
class BlogData
{
    private Integer code;
    
    private String message;
    
    private String traceId;
    
    private Record data;
}

@Data
class Record
{
    private List<SubList> list;
    
    private Long total;
}

@Data
class SubList
{
    String articleId;
    
    String title;
    
    String description;
    
    String url;
    
    Integer type;
    
    String top;
    
    String forcePlan;
    
    Long viewCount;
    
    Long commentCount;
    
    String editUrl;
    
    String postTime;
    
    Long diggCount;
    
    String formatTime;
    
    Object picList;
    
    Long collectCount;
}

3.)解析json字符串

        ObjectMapper mapper = new ObjectMapper();
        String url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";
        String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();
        BlogData blogData = mapper.readValue(resp, BlogData.class);
        log.info("blogData: {} ", blogData);

4.)运行结果

在这里插入图片描述

4. 过程分析

分析整个json数据解析过程,我们发现在实体定义步骤上,花费了我们太多精力和时间,而且一旦json数据key命名有变化或属性名命名不对应,便会打印类似下面的错误信息:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "collectCount" (class com.fly.test.restful.json.SubList), not marked as ignorable (15 known properties: "formatTime", "editUrl", "picList", "viewCount", "collectCount1", "postTime", "url", "commentCount", "articleId", "forcePlan", "top", "title", "type", "description", "diggCount"])
 at [Source: (String)"{"code":200,"message":"success","traceId":"ce6fbb2f-72da-4a9c-9cf4-4e532a942210","data":{"list":[{"articleId":135244727,"title":"java lambda表达式训练题一","description":"Lambda 表达式,也可称为闭包,它是推动 Java 8 发布的最重要新特性。Lambda 允许把函数作为一个方法的参数(函数作为参数传递进方法中)。使用 Lambda 表达式可以使代码变的更加简洁紧凑。","url":"https://blog.csdn.net/qq_16127313/article/details/135244727","type":1,"top":false,"forcePlan":false,"viewCount":1081,"commentCount":0,"editUrl":"https://editor.csdn.net/md?articleId=135244727","postTime":"2023-12-27 18:07:30"[truncated 2457 chars]; line: 1, column: 645] (through reference chain: com.fly.test.restful.json.BlogData["data"]->com.fly.test.restful.json.Record["list"]->java.util.ArrayList[0]->com.fly.test.restful.json.SubList["collectCount"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:840)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1206)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1592)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1570)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3173)
	at com.fly.test.restful.json.ParseJson.test2(ParseJson.java:57)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
	at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
	at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:137)
	at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

四、具体实现二

在上面的实现中,通过分析得知,我们关注的信息只有url、viewCount这2个字段值,并不关心其他字段信息。
在【随笔】java工程中JSON 字符串格式化输出 中我们已经实现了将json字符串格式化后输出,仔细观察输出信息,会发现简单数据对象(如key、value均为字符串、数字等类型数据)均在同一行,这样我们通过解析输出的行字符串信息,便能得到对应信息。

1. 核心代码


        // 调用接口
        String url = "https://blog.csdn.net/community/home-api/v1/get-business-list?page=1&size=5&businessType=blog&username=qq_16127313";
        String resp = webClient.get().uri(url).acceptCharset(StandardCharsets.UTF_8).accept(MediaType.APPLICATION_JSON).retrieve().bodyToMono(String.class).block();
        
        // 数据格式化-jackson格式化后会在:前后添加空格
        String pretty = mapper.readTree(resp).toPrettyString();
        List<String> lines = IOUtils.readLines(new StringReader(pretty));
        
        // 获取url
        List<String> urls = lines.stream().filter(line -> StringUtils.contains(line, "\"url\"")).map(n -> StringUtils.substringBetween(n, " : \"", "\",")).collect(Collectors.toList());
        urls.stream().forEach(log::info);
        
        // 获取viewCount
        List<String> viewCounts = lines.stream().filter(line -> StringUtils.contains(line, "\"viewCount\"")).map(n -> StringUtils.substringBetween(n, " : ", ",")).collect(Collectors.toList());
        viewCounts.stream().forEach(log::info);
    

2.运行结果

在这里插入图片描述

五、方案比较

目标方案一方案二
复杂度复杂简单
健壮性稍不足,需保证实体属性与json key全部严格对应健壮,只需保证获取数据key正确

六、源码传送

https://gitee.com/00fly/effict-side/blob/master/springboot-cache/src/test/java/com/fly/test/restful/json/ParseJson.java


大家可以根据需要选择方案,有任何问题和建议,都可以向我提问讨论,大家一起进步,谢谢!

-over-

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1369024.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python 自学(七) 之面向对象

目录 1. 类的初始化函数 __init__ P186 2. 动态的为类和对象添加属性 P190 3. 类的访问限制 __xxx P192 4. 类的继承及方法重写 P197 1. 类的初始化函数 __init__ P186 每当创建一个类的实例时&#xff0c;__init__都会被执…

C#高级 10 Linq操作

1.Linq操作介绍 Linq操作是C#集成的类似于数据库语言的操作&#xff0c;是通过将数据库的表名映射为类&#xff0c;把数据库的列名映射为属性。 Linq查询主要分为3类&#xff1a;Linq to object(数组、list集合) --内存里面的数据 Linq to sql(查询数据库用的) --在数据库数据…

告别冗余空白,批量删除空白行

你是否遇到过这样的尴尬情况&#xff1a;花费了大量时间整理的文档&#xff0c;却在最后发现其中充斥着无用的空白行&#xff0c;这些多余的空行不仅影响美观&#xff0c;还让整个文档显得杂乱无章。今天&#xff0c;我要给大家介绍一款强大且实用的工具——首助编辑高手&#…

Go采集1688网站数据对比商品价格

最近看了下多多和1688的一些商品价格&#xff0c;发现好多店铺都是无货源拿货一件发货&#xff0c;这就导致层层叠加价格翻了不知道几倍&#xff0c;真所谓多花钱办的事还是一样&#xff0c;因此&#xff0c;今天我就通过一个爬虫程序监控对应商品价格&#xff0c;了解行业龙头…

Java 最小优先队列API设计与实现

Java 学习面试指南&#xff1a;https://javaxiaobear.cn 最小的元素放在数组的索引1处。每个结点的数据总是小于等于它的两个子结点的数据。 1、API设计 类名MinPriorityQueue构造方法MinPriorityQueue(int capacity)&#xff1a;创建容量为capacity的MinPriorityQueue对象成员…

Oracle11.2.0.4从RMAN备份中快速恢复单个表的方法

文章目录 前言一、查询所要恢复的表所涉及的表空间二、创建用于恢复的数据库三、恢复步骤1.恢复控制文件2.修改redo日志名称3.表空间恢复4.表空间recover5.查询数据 前言 由于用户误操作导致某表中的数据错乱&#xff0c;导致业务不能正常使用&#xff0c;现需要将该表恢复到一…

国家数据局——《“数据要素×”三年行动计划(2024—2026年)》

为深入贯彻党的二十大和中央经济工作会议精神&#xff0c;充分发挥数据要素乘数效应&#xff0c;赋能经济社会发展&#xff0c;近日&#xff0c;国家数据局会同中央网信办、科技部、工业和信息化部、交通运输部、等部门联合印发《“数据要素”三年行动计划&#xff08;2024—20…

VS中打开ui文件闪退

解决办法&#xff1a; 依次点击《扩展》-> 《Qt vs tools》-> 《options》-> 《Qt》-> 《general》 -> 《Qt Designer》 -> 《run in detached window》 -> true

Swift单元测试Quick+Nimble

文章目录 使用QuickNimble1、苹果官方测试框架XCTest的优缺点2、选择QuickNimble的原因&#xff1a;3、QuickNimble使用介绍集成&#xff1a;Quick关键字说明&#xff1a;Nimble中的匹配函数等值判断&#xff1a;使用equal函数是否是同一个对象&#xff1a;使用beIdenticalTo函…

java智慧医院互联网智慧3D导诊系统源码,经由智慧导诊系统多维度计算,准确推荐科室

什么是智慧导诊系统? 简单地说&#xff0c;智慧导诊系统是一种利用人工智能技术&#xff0c;为医生提供帮助的系统。它可以通过分析患者的症状和病史为医生提供疾病诊断和治疗方案的建议。 系统介绍&#xff1a; 医院智慧导诊系统是在医院中使用的引导患者自助就诊挂号&…

Python单继承,子类调用父类方法,使用super关键字

但是这么写话还是并不符合我们平时写代码的规范&#xff0c;一般都是用super来调用&#xff0c;贴代码&#xff1a; # 面向对象的3大特征&#xff1a;继承性&#xff0c;封装性&#xff0c;多态性 class Human():sum1 0def __init__(self, name, age):self.name nameself.ag…

机器学习指南:如何学习机器学习?

机器学习 一、介绍 你有没有想过计算机是如何从数据中学习和变得更聪明的&#xff1f;这就是机器学习 &#xff08;ML&#xff09; 的魔力&#xff01;这就像计算机科学和统计学的酷炫组合&#xff0c;计算机从大量信息中学习以解决问题并做出预测&#xff0c;就像人类一样。 …

前端国际化之痛点(二):多包多库场景下联动多语言

前言 VoerkaI18n是一款非常优秀的前端国际化解决方案&#xff0c;其开发的出发点是为了解决现存多语言的一些痛点,接下来几篇文章将分别进行分析。 前端国际化之痛点(一)&#xff1a;让人头疼的词条Key前端国际化之痛点(二)&#xff1a;多包多库场景下联动多语言前端国际化之…

JavaScript数组sort()对负数排序的陷阱

前言 想着好久没去力扣刷题了&#xff0c;刚好手上的需求也差不多了&#xff0c;就去看了看。看到一个难度级别为困难的题&#xff0c;看到这个题想着直接使用JS现成的方法&#xff0c;先concat再sort。再取中间值不就实现了吗。是不是你们也这么想&#xff0c;哈哈哈。 就是…

人逢三六九,运势低迷路难走

很多人都希望自己各方面的运势都能够朝着好的方向旺盛发展&#xff0c;我们的运势将会如何发展跟我们的出生时间是离不开关系的。我们的祖先为了后人着想&#xff0c;不犯他们犯过的错误&#xff0c;少走一些弯路&#xff0c;总结了多年来的生活经验&#xff0c;创造出了一句句…

Unity3d 实现直播功能(无需sdk接入)

Unity3d 实现直播功能 需要插件 :VideoCapture 插件地址(免费的就行) 原理:客户端通过 VideoCapture 插件实现推流nodejs视频流转服务进行转发,播放器实现rtmp拉流 废话不多说,直接上 CaptureSource我选择的是屏幕录制,也可以是其他源 CaptureType选择LIVE–直播形式 LiveSt…

【面试高频算法解析】算法练习2 回溯(Backtracking)

前言 本专栏旨在通过分类学习算法&#xff0c;使您能够牢固掌握不同算法的理论要点。通过策略性地练习精选的经典题目&#xff0c;帮助您深度理解每种算法&#xff0c;避免出现刷了很多算法题&#xff0c;还是一知半解的状态 专栏导航 二分查找回溯&#xff08;Backtracking&…

苹果QQ群聊天记录怎么删除?收藏好这两个技巧!

无论我们使用什么手机&#xff0c;我们都可以在QQ上与好友进行交流和社交。然而&#xff0c;有时候我们可能需要删除一些不需要的聊天记录&#xff0c;特别是群聊记录&#xff0c;以此来扩大手机内存。那么&#xff0c;苹果手机的qq群聊天记录怎么删除呢&#xff1f;小编将为大…

电子学会C/C++编程等级考试2023年12月(一级)真题解析

C/C++编程(1~8级)全部真题・点这里 第1题:数的输入和输出 输入一个整数和双精度浮点数,先将浮点数保留2位小数输出,然后输出整数。 时间限制:1000 内存限制:65536 输入 一行两个数,分别为整数N(不超过整型范围),双精度浮点数F,以一个空格分开。 输出 一行两个数,分…

使用 C# 和 WinForms 创建动态图表

使用 C# 和 WinForms 创建动态图表 这次我们将学习如何使用 C# 和 WinForms 创建动态图表。我们将使用 Chart 控件来创建图表&#xff0c;并使用多线程技术实现动态更新图表数据的效果。 方法一&#xff1a;在项目启动时实例化图表 在 DoWork 方法中&#xff0c;我们使用 Ra…