业务场景中Hive解析Json常用案例

业务场景中Hive解析Json常用案例

json在线工具

  • json格式转换在线工具
https://tool.lu/json/

  • format格式互转:
// 格式化可以合并整行显示
{"name":"John Doe","age":35,"email":"john@example.com"}// 格式化可以展开显示,示例数据更清晰
{"name": "John Doe","age": 35,"email": "john@example.com"
}
  • 转化常用yaml格式

工具提供了各种跨格式转化

age: 35
email: john@example.com
name: 'John Doe'

根据json串自动生成生成 Java 类等功能也非常实用

示例准备

需要Hive环境

  • test测试表
-- 在Hive中建测试表
CREATE TABLE json_test_table (id INT,json_column STRING
) STORED AS TEXTFILE;

json_column 字段用来存储需要处理的 json 串

示例 1: 提取单个字段

假设 JSON 数据包含用户信息

{"name": "John Doe","age": 35,"email": "john@example.com"
}
  • 样例数据
insert into json_test_table values (1,'{"name":"John Doe","age":35,"email":"john@example.com"}');select * from json_test_table where id = 1;
+------+---------------------------------------------------------+
| id   | json_column                                             |
+------+---------------------------------------------------------+
|    1 | {"name":"John Doe","age":35,"email":"john@example.com"} |
+------+---------------------------------------------------------+

使用 get_json_object 函数从 JSON 中提取字段:

SELECT get_json_object(json_column, '$.name') AS name FROM json_test_table where id = 1;+-----------+
|   name    |
+-----------+
| John Doe  |
+-----------+
1 row selected (19.655 seconds)SELECT get_json_object(json_column, '$.name') AS name,get_json_object(json_column, '$.age') AS age FROM json_test_table where id = 1;
+-----------+------+
|   name    | age  |
+-----------+------+
| John Doe  | 35   |
+-----------+------+
1 row selected (19.396 seconds)

示例 2: 提取嵌套字段

在 JSON 数据中有嵌套字段的情况下:

{"user": {"name": "Alice","address": {"city": "New York","zipcode": "10001"}}
}
  • 样例数据
insert into json_test_table values (2,'{"user":{"name":"Alice","address":{"city":"New York","zipcode":"10001"}}}');select * from json_test_table where id = 2;
+------+---------------------------------------------------------------------------+
| id   | json_column                                                               |
+------+---------------------------------------------------------------------------+
|    2 | {"user":{"name":"Alice","address":{"city":"New York","zipcode":"10001"}}} |
+------+---------------------------------------------------------------------------+

提取嵌套字段的值:

SELECT get_json_object(json_column, '$.user.name') AS user_name,get_json_object(json_column, '$.user.address.city') AS city
FROM json_test_table where id = 2;+------------+-----------+
| user_name  |   city    |
+------------+-----------+
| Alice      | New York  |
+------------+-----------+
1 row selected (19.38 seconds)

示例 3: 提取数组中的值

假设 JSON 数据包含一个数组:

{"tags": ["apple", "banana", "orange"]
}
  • 样例数据
insert into json_test_table values (3,'{"tags":["apple","banana","orange"]}');select * from json_test_table where id = 3;
+------+--------------------------------------+
| id   | json_column                          |
+------+--------------------------------------+
|    3 | {"tags":["apple","banana","orange"]} |
+------+--------------------------------------+

从数组中提取值:

SELECT get_json_object(json_column, '$.tags[0]') AS first_tag,get_json_object(json_column, '$.tags[1]') AS second_tag
FROM json_test_table where id = 3;+------------+-------------+
| first_tag  | second_tag  |
+------------+-------------+
| apple      | banana      |
+------------+-------------+
1 row selected (18.488 seconds)

示例 4: 提取数组列表长度

获取数组的长度:

-- 复用 示例3中样例数据
select * from json_test_table where id = 3;
+------+--------------------------------------+
| id   | json_column                          |
+------+--------------------------------------+
|    3 | {"tags":["apple","banana","orange"]} |
+------+--------------------------------------+
-- 可以看到数组tags对应的值有3个SELECT size(split(get_json_object(json_column, '$.tags'), ',')) AS tags_length
FROM json_test_table
WHERE id = 3;+--------------+
| tags_length  |
+--------------+
| 3            |
+--------------+
1 row selected (35.766 seconds)

示例 5:业务场景-解析公司基本信息案例

  • 假设JSON数据包含公司的基本信息,比如公司名称、注册资本等字段
{"company_name": "wangting_company","registration": {"registered_capital": 1000000,"registered_date": "2020-01-01","registered_address": "123 Main St, City"}
}{"company_name":"wangting_company","registration":{"registered_capital":1000000,"registered_date":"2020-01-01","registered_address":"123 Main St, City"}}
-- 创建表
CREATE TABLE company_info (company_name STRING,registered_capital INT,registered_date STRING,registered_address STRING
) STORED AS TEXTFILE;-- 转化插入数据
INSERT INTO company_info
SELECTget_json_object(json_data, '$.company_name') AS company_name,get_json_object(json_data, '$.registration.registered_capital') AS registered_capital,get_json_object(json_data, '$.registration.registered_date') AS registered_date,get_json_object(json_data, '$.registration.registered_address') AS registered_address
FROM(SELECT '{"company_name": "wangting_company", "registration": {"registered_capital": 1000000, "registered_date": "2020-01-01", "registered_address": "123 Main St, City"}}' AS json_data) t;+----------------------------+----------------------------------+-------------------------------+----------------------------------+
| company_info.company_name  | company_info.registered_capital  | company_info.registered_date  | company_info.registered_address  |
+----------------------------+----------------------------------+-------------------------------+----------------------------------+
| wangting_company           | 1000000                          | 2020-01-01                    | 123 Main St, City                |
+----------------------------+----------------------------------+-------------------------------+----------------------------------+
1 row selected (0.411 seconds)

示例 6: 使用 LATERAL VIEW 解析数组

使用 LATERAL VIEWexplode 解析 JSON 数组:

-- 复用示例3样例数据
SELECT id, tag
FROM json_test_table
LATERAL VIEW explode(split(get_json_object(json_column, '$.tags'), ',')) exploded_tags AS tag
WHERE id = 3;+-----+------------+
| id  |    tag     |
+-----+------------+
| 3   | ["apple"   |
| 3   | "banana"   |
| 3   | "orange"]  |
+-----+------------+
3 rows selected (17.318 seconds)-- 仅展示解析数据,实际使用如需去除方括号,可以一并清洗

示例 7: 提取数组对象的值

如果数组包含对象,则提取对象的值:

{"users": [{"name": "Alice","age": 28},{"name": "Bob","age": 35}]
}{"users":[{"name":"Alice","age":28},{"name":"Bob","age":35}]}
  • 样例数据
insert into json_test_table values (7,'{"users":[{"name":"Alice","age":28},{"name":"Bob","age":35}]}');select * from json_test_table where id = 7;
+------+---------------------------------------------------------------+
| id   | json_column                                                   |
+------+---------------------------------------------------------------+
|    7 | {"users":[{"name":"Alice","age":28},{"name":"Bob","age":35}]} |
+------+---------------------------------------------------------------+
SELECT get_json_object(json_column, '$.users[0].name') AS user1_name,get_json_object(json_column, '$.users[1].name') AS user2_name
FROM json_test_table where id = 7;+-------------+-------------+
| user1_name  | user2_name  |
+-------------+-------------+
| Alice       | Bob         |
+-------------+-------------+
1 row selected (17.372 seconds)

示例 8: 处理日期

处理 JSON 中的日期字段:

{"event_date": "2023-11-21"
}{"event_date":"2023-11-21"}
  • 样例数据
insert into json_test_table values (8,'{"event_date":"2023-11-21"}');select * from json_test_table where id = 8;
+------+-----------------------------+
| id   | json_column                 |
+------+-----------------------------+
|    8 | {"event_date":"2023-11-21"} |
+------+-----------------------------+
SELECT get_json_object(json_column, '$.event_date') AS event_date
FROM json_test_table where id = 8;+-------------+
| event_date  |
+-------------+
| 2023-11-21  |
+-------------+
1 row selected (17.436 seconds)SELECT id, CAST(get_json_object(json_column, '$.event_date') AS DATE) AS event_date,YEAR(CAST(get_json_object(json_column, '$.event_date') AS DATE)) AS event_year,MONTH(CAST(get_json_object(json_column, '$.event_date') AS DATE)) AS event_month
FROM json_test_table
WHERE id = 8;+-----+-------------+-------------+--------------+
| id  | event_date  | event_year  | event_month  |
+-----+-------------+-------------+--------------+
| 8   | 2023-11-21  | 2023        | 11           |
+-----+-------------+-------------+--------------+
1 row selected (17.363 seconds)

示例 9: 提取布尔值

提取 JSON 中的布尔字段:

{"is_active": true
}{"is_active":true}
  • 样例数据
insert into json_test_table values (9,'{"is_active":true}');select * from json_test_table where id = 9;
+------+--------------------+
| id   | json_column        |
+------+--------------------+
|    9 | {"is_active":true} |
+------+--------------------+
SELECT get_json_object(json_column, '$.is_active') AS is_active
FROM json_test_table where id = 9;
+------------+
| is_active  |
+------------+
| true       |
+------------+
1 row selected (18.401 seconds)--  使用WHERE子句根据布尔值进行条件过滤。
SELECT *
FROM json_test_table
WHERE get_json_object(json_column, '$.is_active') = 'true';+---------------------+------------------------------+
| json_test_table.id  | json_test_table.json_column  |
+---------------------+------------------------------+
| 9                   | {"is_active":true}           |
+---------------------+------------------------------+
1 row selected (17.327 seconds)

示例 10: json_tuple计算 JSON 对象数量

计算 JSON 对象中包含的键值对数量:

SELECT json_tuple(json_column, 'name', 'age') AS (name, age)
FROM json_test_table;+-----------+-------+
|   name    |  age  |
+-----------+-------+
| John Doe  | 35    |
| NULL      | NULL  |
| NULL      | NULL  |
| NULL      | NULL  |
| NULL      | NULL  |
| NULL      | NULL  |
+-----------+-------+
6 rows selected (17.344 seconds)-- 只有id=1符合条件 不符合条件均为NULL

示例 11: 使用 json_tuple 提取值

从 JSON 对象中使用 json_tuple 提取多个字段:

{"name": "John","age": 30,"address": "New York"
}{"name":"John","age":30,"address":"New York"}
  • 样例数据
insert into json_test_table values (11,'{"name":"John","age":30,"address":"New York"}');select * from json_test_table where id = 11;
+------+-----------------------------------------------+
| id   | json_column                                   |
+------+-----------------------------------------------+
|   11 | {"name":"John","age":30,"address":"New York"} |
+------+-----------------------------------------------+
SELECT json_tuple(json_column, 'name', 'age', 'address') AS (name, age, address)
FROM json_test_table where id = 11;+-------+------+-----------+
| name  | age  |  address  |
+-------+------+-----------+
| John  | 30   | New York  |
+-------+------+-----------+
1 row selected (17.414 seconds)

示例 12: 提取数字字段

从 JSON 中提取数字字段:

{"count": 50
}{"count":50}
  • 样例数据
insert into json_test_table values (12,'{"count":50}');select * from json_test_table where id = 12;
+------+--------------+
| id   | json_column  |
+------+--------------+
|   12 | {"count":50} |
+------+--------------+
SELECT get_json_object(json_column, '$.count') AS count
FROM json_test_table where id = 12;+--------+
| count  |
+--------+
| 50     |
+--------+
1 row selected (19.401 seconds)

示例 13: 使用 get_json_object 过滤数据

根据 JSON 中的字段值进行过滤:

SELECT *
FROM json_test_table
WHERE get_json_object(json_column, '$.age') > 30;+---------------------+----------------------------------------------------+
| json_test_table.id  |            json_test_table.json_column             |
+---------------------+----------------------------------------------------+
| 1                   | {"name":"John Doe","age":35,"email":"john@example.com"} |
+---------------------+----------------------------------------------------+
1 row selected (18.402 seconds)SELECT *
FROM json_test_table
WHERE get_json_object(json_column, '$.age') > 10;+---------------------+----------------------------------------------------+
| json_test_table.id  |            json_test_table.json_column             |
+---------------------+----------------------------------------------------+
| 1                   | {"name":"John Doe","age":35,"email":"john@example.com"} |
| 11                  | {"name":"John","age":30,"address":"New York"}      |
+---------------------+----------------------------------------------------+
2 rows selected (17.298 seconds)

示例 14: 处理空值

处理 JSON 数据中可能的空值:

{"status": null
}{"status":null}
  • 样例数据
insert into json_test_table values (14,'{"status":null}');select * from json_test_table where id = 14;
+------+-----------------+
| id   | json_column     |
+------+-----------------+
|   14 | {"status":null} |
+------+-----------------+
SELECT get_json_object(json_column, '$.status') AS status
FROM json_test_table where id = 14;+---------+
| status  |
+---------+
| NULL    |
+---------+
1 row selected (17.345 seconds)--  使用IS NULL或IS NOT NULL来检查字段是否为空
SELECT id, json_column
FROM json_test_table
WHERE id = 14 AND get_json_object(json_column, '$.status') IS NULL;+-----+------------------+
| id  |   json_column    |
+-----+------------------+
| 14  | {"status":null}  |
+-----+------------------+
1 row selected (17.47 seconds)-- 使用CASE语句对NULL值进行处理或者转换为其他值。
SELECT id, CASE WHEN get_json_object(json_column, '$.status') IS NULL THEN 'No Status' ELSE get_json_object(json_column, '$.status') END AS status
FROM json_test_table
WHERE id = 14;+-----+------------+
| id  |   status   |
+-----+------------+
| 14  | No Status  |
+-----+------------+
1 row selected (17.31 seconds)

示例 15: 使用 get_json_object 判断是否存在字段

判断 JSON 是否包含特定字段:

SELECT CASE WHEN get_json_object(json_column, '$.name') IS NOT NULL THEN 'Exists' ELSE 'Not Exists' END AS field_status
FROM json_test_table;
+---------------+
| field_status  |
+---------------+
| Exists        |
| Not Exists    |
| Exists        |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
+---------------+SELECT CASE WHEN get_json_object(json_column, '$.age') IS NOT NULL THEN 'Exists' ELSE 'Not Exists' END AS field_status
FROM json_test_table;+---------------+
| field_status  |
+---------------+
| Exists        |
| Not Exists    |
| Exists        |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
+---------------+SELECT CASE WHEN get_json_object(json_column, '$.aaaaaaaaa') IS NOT NULL THEN 'Exists' ELSE 'Not Exists' END AS field_status
FROM json_test_table;+---------------+
| field_status  |
+---------------+
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
| Not Exists    |
+---------------+
9 rows selected (17.337 seconds)

示例 16: 提取多层嵌套对象的值

从多层嵌套的 JSON 对象中提取值:

{"user": {"details": {"name": "Alice","age": 30}}
}{"user":{"details":{"name":"Alice","age":30}}}
  • 样例数据
insert into json_test_table values (16,'{"user":{"details":{"name":"Alice","age":30}}}');select * from json_test_table where id = 16;
+------+------------------------------------------------+
| id   | json_column                                    |
+------+------------------------------------------------+
|   16 | {"user":{"details":{"name":"Alice","age":30}}} |
+------+------------------------------------------------+
SELECT get_json_object(json_column, '$.user.details.name') AS user_name,get_json_object(json_column, '$.user.details.age') AS user_age
FROM json_test_table where id = 16;+------------+-----------+
| user_name  | user_age  |
+------------+-----------+
| Alice      | 30        |
+------------+-----------+
1 row selected (16.253 seconds)

示例 17: 提取嵌套对象数组的值

从嵌套的对象数组中提取值:

{"employees": [{"name": "Alice","department": "HR"},{"name": "Bob","department": "Engineering"}]
}{"employees":[{"name":"Alice","department":"HR"},{"name":"Bob","department":"Engineering"}]}
  • 样例数据
insert into json_test_table values (17,'{"employees":[{"name":"Alice","department":"HR"},{"name":"Bob","department":"Engineering"}]}');select * from json_test_table where id = 17;
+------+----------------------------------------------------------------------------------------------+
| id   | json_column                                                                                  |
+------+----------------------------------------------------------------------------------------------+
|   17 | {"employees":[{"name":"Alice","department":"HR"},{"name":"Bob","department":"Engineering"}]} |
+------+----------------------------------------------------------------------------------------------+
SELECT get_json_object(json_column, '$.employees[0].name') AS employee1_name,get_json_object(json_column, '$.employees[1].name') AS employee2_name
FROM json_test_table where id = 17;+-----------------+-----------------+
| employee1_name  | employee2_name  |
+-----------------+-----------------+
| Alice           | Bob             |
+-----------------+-----------------+
1 row selected (17.273 seconds)

示例 18: 提取数组对象的多个值

取数组对象的多个值

从数组对象中提取多个值:

{"items": [{"id": 1,"name": "Item 1"},{"id": 2,"name": "Item 2"}]
}{"items":[{"id":1,"name":"Item 1"},{"id":2,"name":"Item 2"}]}
  • 样例数据
insert into json_test_table values (18,'{"items":[{"id":1,"name":"Item 1"},{"id":2,"name":"Item 2"}]}');select * from json_test_table where id = 18;
+------+---------------------------------------------------------------+
| id   | json_column                                                   |
+------+---------------------------------------------------------------+
|   18 | {"items":[{"id":1,"name":"Item 1"},{"id":2,"name":"Item 2"}]} |
+------+---------------------------------------------------------------+
SELECT get_json_object(json_column, '$.items[0].id') AS item1_id,get_json_object(json_column, '$.items[0].name') AS item1_name,get_json_object(json_column, '$.items[1].id') AS item2_id,get_json_object(json_column, '$.items[1].name') AS item2_name
FROM json_test_table where id = 18;+-----------+-------------+-----------+-------------+
| item1_id  | item1_name  | item2_id  | item2_name  |
+-----------+-------------+-----------+-------------+
| 1         | Item 1      | 2         | Item 2      |
+-----------+-------------+-----------+-------------+
1 row selected (17.386 seconds)

示例19: json_serde解析映射数据文件的使用介绍

  • json_serde库提供了一种在Hive中直接将JSON格式的数据解析成表的方式,可简化处理流程。

如果现在有一个json文件:

[app@ali-wangting wangt]$ cat wangt.json

{"name":"wangting01","age":21,"email":"wangting01@example.com"}
{"name":"wangting02","age":22,"email":"wangting02@example.com"}
{"name":"wangting03","age":23,"email":"wangting03@example.com"}
{"name":"wangting04","age":24,"email":"wangting04@example.com"}
{"name":"wangting05","age":25,"email":"wangting05@example.com"}
{"name":"wangting06","age":26,"email":"wangting06@example.com"}
{"name":"wangting07","age":27,"email":"wangting07@example.com"}
{"name":"wangting08","age":28,"email":"wangting08@example.com"}

现在希望建立一张表,使得表可以直接映射上数据文件

  • hive中建表
CREATE TABLE IF NOT EXISTS wangt_666_json(name string,age int,email string
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
stored as textfile;desc wangt_json_table;
+-----------+------------+--------------------+
| col_name  | data_type  |      comment       |
+-----------+------------+--------------------+
| name      | string     | from deserializer  |
| age       | int        | from deserializer  |
| email     | string     | from deserializer  |
+-----------+------------+--------------------+
  • 将json文件上传至建表对应hdfs路径
[app@ali-wangting wangt]$ hdfs dfs -ls /user/hive/warehouse/wangt.db/wangt_666_json/
[app@ali-wangting wangt]$ hdfs dfs -put wangt.json /user/hive/warehouse/wangt.db/wangt_666_json/
[app@ali-wangting wangt]$ hdfs dfs -ls /user/hive/warehouse/wangt.db/wangt_666_json/
Found 1 items
-rwxrwx--x+  2 hive hive        512 2023-12-04 16:38 /user/hive/warehouse/wangt.db/wangt_666_json/wangt.json# 也可以通过hive的sql命令行直接load数据文件
load data local inpath '/home/wangt/wangt.json' into table wangt_666_json;
  • 查看表数据验证
select * from wangt_666_json;
+----------------------+---------------------+-------------------------+
| wangt_666_json.name  | wangt_666_json.age  |  wangt_666_json.email   |
+----------------------+---------------------+-------------------------+
| wangting01           | 21                  | wangting01@example.com  |
| wangting02           | 22                  | wangting02@example.com  |
| wangting03           | 23                  | wangting03@example.com  |
| wangting04           | 24                  | wangting04@example.com  |
| wangting05           | 25                  | wangting05@example.com  |
| wangting06           | 26                  | wangting06@example.com  |
| wangting07           | 27                  | wangting07@example.com  |
| wangting08           | 28                  | wangting08@example.com  |
+----------------------+---------------------+-------------------------+
8 rows selected (0.5 seconds)

可以看到数据文件8行记录,成功映射对应了hive中wangt_666_json表的8条数据

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

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

相关文章

(一)rtthread主线程启动流程

(一)rtthread主线程启动流程 声明1.启动分析2.源码分析 声明 本文主要为个人学习笔记内容总结,有来自网络及其他,如有雷同,请告知。 1.启动分析 基于:rt-thread-v5.0.1 先执行:汇编代码start…

Implicit Neural Representation for Cooperative Low-light Image Enhancement

GitHub - Ysz2022/NeRCo: [ICCV 2023] Implicit Neural Representation for Cooperative Low-light Image Enhancement 参考:ICCV2023 | 将隐式神经表征用于“低光增强”,北大张健团队提出NeRCo (qq.com) 以下三个因素限制了现有低光图像增强方法的应用…

workbench导入sql脚本文件

这里面有个Data Import 点击start Import 刷新一下导入完成

C++多态(详解)

一、多态的概念 1.1、多态的概念 多态:多种形态,具体点就是去完成某个行为,当不同的对象去完成时会产生出不同的状态。 举个例子:比如买票这个行为,当普通人买票时,是全价买票;学生买票时&am…

故宫博物院与周大福珠宝集团 战略合作签约仪式在京举行

12月5日上午,故宫博物院与周大福珠宝集团战略合作签约仪式在故宫博物院故宫文化资产数字化应用研究所举行。文化和旅游部党组成员、故宫博物院院长王旭东,国际儒学联合会常务副会长、原文化部副部长丁伟,国际儒学联合会特别顾问、中国国际友好…

深入了解Java Duration类,对时间的精细操作

阅读建议 嗨,伙计!刷到这篇文章咱们就是有缘人,在阅读这篇文章前我有一些建议: 本篇文章大概6000多字,预计阅读时间长需要5分钟。本篇文章的实战性、理论性较强,是一篇质量分数较高的技术干货文章&#x…

12.Java程序设计-基于Springboot框架的Android学习生活交流APP设计与实现

摘要 移动应用在日常生活中扮演着越来越重要的角色,为用户提供了方便的学习和生活交流渠道。本研究旨在设计并实现一款基于Spring Boot框架的Android学习生活交流App,以促进用户之间的信息分享、学术交流和社交互动。 在需求分析阶段,我们明…

如何使用HadSky搭配内网穿透工具搭建个人论坛并发布至公网随时随地可访问

文章目录 前言1. 网站搭建1.1 网页下载和安装1.2 网页测试1.3 cpolar的安装和注册 2. 本地网页发布2.1 Cpolar临时数据隧道2.2 Cpolar稳定隧道(云端设置)2.3 Cpolar稳定隧道(本地设置)2.4 公网访问测试 总结 前言 经过多年的基础…

【微服务】springboot整合quartz使用详解

目录 一、前言 二、quartz介绍 2.1 quartz概述 2.2 quartz优缺点 2.3 quartz核心概念 2.3.1 Scheduler 2.3.2 Trigger 2.3.3 Job 2.3.4 JobDetail 2.4 Quartz作业存储类型 2.5 适用场景 三、Cron表达式 3.1 Cron表达式语法 3.2 Cron表达式各元素说明 3.3 Cron表达…

浅谈https

1.网络传输的安全性 http 协议:不安全,未加密https 协议:安全,对请求报文和响应报文做加密 2.对称加密与非对称加密 2.1 对称加密 特点: 加解密使用 相同 秘钥 高效,适用于大量数据的加密场景 算法公开&a…

C++STL的string类(一)

文章目录 前言C语言的字符串 stringstring类的常用接口string类的常见构造string (const string& str);string (const string& str, size_t pos, size_t len npos); capacitysize和lengthreserveresizeresize可以删除数据 modify尾插插入字符插入字符串 inserterasere…

7.3 Windows驱动开发:内核监视LoadImage映像回调

在笔者上一篇文章《内核注册并监控对象回调》介绍了如何运用ObRegisterCallbacks注册进程与线程回调,并通过该回调实现了拦截指定进行运行的效果,本章LyShark将带大家继续探索一个新的回调注册函数,PsSetLoadImageNotifyRoutine常用于注册Loa…

学习IO的第五天

作业 &#xff1a;使用两个线程完成文件的拷贝写入&#xff0c;分线程1写入前半段&#xff0c;分线程2写入后半段&#xff0c;主线程用来回收资源 #include <head.h>void *sork(void *arg); void *sork2(void *arg);int file_copy(int start,int len) //拷贝的函数 {i…

Linux_vi/vim编辑器

3.VI 与 VIM 3.1概述 vi编辑器&#xff1a;是Linux和Unix上最基本的文本编辑器&#xff0c;工作在字符模式下。由于不需要图形界面&#xff0c;vi是效率很高的文本编辑器。 vim是&#xff1a;vi的增强版&#xff0c;比vi更容易使用。vi的命令几乎全部都可以在vim上使用。 3…

Qt图形设计

#include "mywidget.h"MyWidget::MyWidget(QWidget *parent): QWidget(parent) {//窗口相关设置//设置窗口标题this->setWindowTitle("王者荣耀");//设置窗口图标this->setWindowIcon(QIcon("C:\\Users\\28033\\Pictures\\Saved Pictures\\pict…

ESP32单片机案例

工具&#xff1a;VScode PlatformIO IDE 注&#xff1a;B站视频学习笔记。 1、继电器 1&#xff09;硬件电路 2&#xff09;程序 #include <Arduino.h> #define RELAY_PIN 15//初始化定时器 hw_timer_t *timer NULL;void timer_interrupt(){ //将引脚传入的电平信号…

公众号word文档

在数字化时代&#xff0c;信息的快速获取和高效整理变得尤为重要。微信公众号作为信息传播的重要平台&#xff0c;其内容经常需要被转换成更易于编辑和存档的格式&#xff0c;如Word文档。这里&#xff0c;我们将介绍如何利用“微附件”小程序实现这一过程&#xff0c;并分享一…

第二十一章

网络通信这一章 基本分为三个部分 网络基础概念和TCP,UDP这三个部分主要如下&#xff1a; 计算机网络实现了堕胎计算机间的互联&#xff0c;使得它们彼此之间能够进行数据交流。网络应用程序就是再已连接的不同计算机上运行的程序&#xff0c;这些程序借助于网络协议&#xf…

mixamo根动画导入UE5问题:滑铲

最近想做一个跑酷游戏&#xff0c;从mixamo下载滑铲动作后&#xff0c;出了很多动画的问题。花了两周时间&#xff0c;终于是把所有的问题基本上都解决了。 常见问题&#xff1a; 1.【动画序列】人物不移动。 2.【动画序列】人物移动朝向错误。 3.【蒙太奇】人物移动后会被拉回…

谈谈 .NET8 平台中对 LiteDB 的 CRUD 操作

哪个啥&#xff01;纯 C# 编写的 LiteDB 你还不会操作&#xff1f; LiteDB 简介LiteDB 安装1、同步版 LiteDB2、异步版 LiteDB.Async LiteDB StudioLiteDB CRUD 操作举例1、.net cli 命令创建项目2、项目添加相关 nuget 包3、改造项目结构4、改造项目代码 LiteDB vs SQLite 对比…