Mysql中截取json格式内容
2021/11/9 19:44:43
本文主要是介绍Mysql中截取json格式内容,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、首先先观察数据库中的字段中的json格式
然后使用在线json解析工具来看看数据
"formData": { "柜1": "", "柜2": "", "倍率": "1", "备注": "", "主开关": "", "分开关": "", "变压器": "630", "配电房": "1#配电房", "功能区域": "租户用电", "客户名称": "", "是否总表": "分表", "是否收费": "收费" }, "labelWidth": 120, "displayType": "row", "propsSchema": { "type": "object", "required": [], "properties": { "柜1": { "type": "string", "title": "柜1", "format": "string", "message": {}, "ui:width": "50%", "maxLength": 50, "minLength": 1, "ui:hidden": false, "sort_order": 3000, "description": "", "is_required": false, "ui:disabled": false, "ui:readonly": false }, "柜2": { "type": "string", "title": "柜2", "format": "string", "message": {}, "ui:width": "50%", "maxLength": 50, "minLength": 1, "ui:hidden": false, "sort_order": 4000, "is_required": false, "ui:disabled": false, "ui:readonly": false }, "倍率": { "max": 10000, "min": 1, "step": 1, "type": "number", "unit": "倍", "title": "倍率", "default": "1", "message": {}, "ui:width": "50%", "ui:hidden": false, "sort_order": 5000, "ui:options": { "addonAfter": "倍" }, "description": "仪表的实际读数=[获取到的仪表读数]*[倍率]。", "is_required": true, "ui:disabled": false, "ui:readonly": false }, "备注": { "type": "string", "title": "备注", "format": "textarea", "message": {}, "ui:width": "100%", "maxLength": 500, "minLength": 1, "ui:hidden": false, "sort_order": 10000, "ui:options": { "autoSize": { "maxRows": 5, "minRows": 3 } }, "is_required": false, "ui:disabled": false, "ui:readonly": false }, "主开关": { "type": "string", "title": "主开关", "format": "string", "message": {}, "ui:width": "50%", "maxLength": 50, "minLength": 1, "ui:hidden": false, "sort_order": 3000, "ui:options": { "placeholder": "请输入主开关" }, "is_required": false, "ui:disabled": false, "ui:readonly": false }, "分开关": { "type": "string", "title": "分开关", "format": "string", "message": {}, "ui:width": "50%", "maxLength": 50, "minLength": 1, "ui:hidden": false, "sort_order": 4000, "ui:options": { "placeholder": "请输入分开关" }, "is_required": false, "ui:disabled": false, "ui:readonly": false }, "变压器": { "enum": ["630", "1000", "1250", "1600"], "type": "string", "unit": "KVA", "title": "变压器", "format": "string", "default": "630", "ui:width": "50%", "enumNames": ["630", "1000", "1250", "1600"], "ui:hidden": false, "sort_order": 2000, "ui:options": { "addonAfter": "KVA" }, "is_required": true, "ui:disabled": false, "ui:readonly": false }, "配电房": { "enum": ["1#配电房", "2#配电房", "3#配电房"], "type": "string", "title": "配电房", "format": "string", "default": "1#配电房", "ui:width": "50%", "enumNames": ["1#配电房", "2#配电房", "3#配电房"], "ui:hidden": false, "sort_order": 1000, "is_required": true, "ui:disabled": false, "ui:readonly": false }, "功能区域": { "enum": ["租户用电", "物业用电"], "type": "string", "title": "功能区域", "format": "string", "default": "租户用电", "ui:width": "50%", "enumNames": ["租户用电", "物业用电"], "ui:hidden": false, "sort_order": 7000, "is_required": true, "ui:disabled": false, "ui:readonly": false }, "客户名称": { "type": "string", "title": "客户名称", "format": "string", "message": {}, "ui:width": "100%", "maxLength": 500, "minLength": 1, "ui:hidden": false, "sort_order": 9000, "ui:options": {}, "is_required": false, "ui:disabled": false, "ui:readonly": false }, "是否总表": { "enum": ["分表", "总表"], "type": "string", "title": "是否总表", "format": "string", "default": "分表", "ui:width": "50%", "enumNames": ["分表", "总表"], "ui:hidden": false, "sort_order": 8000, "is_required": true, "ui:disabled": false, "ui:readonly": false }, "是否收费": { "enum": ["收费", "不收费"], "type": "string", "title": "是否收费", "format": "string", "default": "收费", "ui:width": "50%", "enumNames": ["收费", "不收费"], "ui:hidden": false, "sort_order": 6000, "is_required": true, "ui:disabled": false, "ui:readonly": false } } }, "showDescIcon": true } { "source": { "id": "53974fb6-a69e-46f3-b8a5-a5b7a80c1917", "user_index": 13413 } }
里面是带有{},所以截取需要个对象, 代码如下:
json_extract(form_json_schema,'$.formData."功能区域"') as sd, json_extract(form_json_schema,'$.formData."是否收费"') as sf, json_extract(form_json_schema,'$.formData."是否总表"') as zf
结果如下:
就可以获取想要的字段,如果是一般没带{},可以直接使用json_extract(form_json_schema,'$.属性') 即可得到想要的结果。
这篇关于Mysql中截取json格式内容的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-26React入门教程:从零开始搭建你的第一个React应用
- 2024-12-25Vue2入门教程:轻松掌握前端开发基础
- 2024-12-25Vue3入门指南:快速搭建你的第一个Vue3项目
- 2024-12-25JS基础知识入门教程
- 2024-12-25React基础知识详解:从入门到初级应用
- 2024-12-25Vue3基础知识详解与实战指南
- 2024-12-25Vue3学习:从入门到初步掌握
- 2024-12-25Vue3入门:新手必读的简单教程
- 2024-12-23【JS逆向百例】爱疯官网登录逆向分析
- 2024-12-21Vue3教程:新手入门到实践应用