mysql - 在 MySQL 中将分号分隔的字符串转换为 JSON 数组
问题描述
我需要创建一个函数,将这些数据:“test1@test.com;test2@test.com”转换为 JSON,如字符串:“[”test1@test.com”,”test2@test.com”]”。
在 MySQL 函数中......有什么想法吗?
解决方案
SET @value := '"test1@test.com;test2@test.com"'; SELECT @value, CONCAT('"[', REPLACE(@value, ';', '", "'), ']"');
@价值 CONCAT('"[', REPLACE(@value, ';', '", "'), ']"') “test1@test.com;test2@test.com” "["test1@test.com", "test2@test.com"]"
db<>在这里摆弄
推荐阅读
- django - Django ImageKit 在管理站点内更改图像尺寸
- python - 如何实现我自己的搜索过滤器 - Django?
- python - Nearest latitude and longitude points in python
- reactjs - react-router-dom V6 中的嵌套路由
- python - 如何使用 IB API 获取当前价格
- javascript - 使用 .reduce() 将数组转换为对象
- spring-kafka - Spring kafka 2.7.8 的 setAckOnError() 方法
- jwt - 如何从 base64 结束字符串创建 Java Key 对象,以便使用 JJWT 进行 PS256 解析
- spring-boot - Spring将保存到数据库与另一个实例同步
- java - 如何将成员添加到数组列表的后面或前面