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-11-19Vue3入门教程:从零开始搭建你的第一个Vue3项目
- 2024-11-19vue2 开发移动端h5 使用那个ui框架比较好?-icode9专业技术文章分享
- 2024-11-19ReactJS结合TypeScript、Vite、Redux和TanStack (React Query) 实战教程
- 2024-11-19Vue3资料入门教程:零基础快速上手指南
- 2024-11-19Vue3资料:新手入门教程与实战指南
- 2024-11-19Vue资料:新手入门vue.js教程与实践指南
- 2024-11-19Vue资料:初学者入门指南
- 2024-11-18tcpdf可以等待vue动态页面加载完成后再生成pdf吗?-icode9专业技术文章分享
- 2024-11-16Vue3资料:新手入门必读教程
- 2024-11-16Vue3资料:新手入门全面指南