场景
Node-RED简介与Windows上安装、启动和运行示例:
Node-RED简介与Windows上安装、启动和运行示例_霸道流氓气质的博客-CSDN博客
Node-RED怎样导出导入流程为json文件:
Node-RED怎样导出导入流程为json文件_霸道流氓气质的博客-CSDN博客
json示例数据如下
[{"title": "ASP.NET網頁程式設計", "author": "陳會安", "category": "Web", "pubdate": "06/2015", "id": "W101"}, {"title": "PHP網頁程式設計", "author": "陳會安", "category": "Web", "pubdate": "07/2015", "id": "W102"}, {"title": "Java程式設計", "author": "陳會安", "category": "Programming", "pubdate": "11/2015", "id": "P102"}, {"title": "Android程式設計", "author": "陳會安", "category": "Mobile", "pubdate": "07/2015", "id": "M102"}]
怎样解析该json数据并获取指定对象的属性。
注:
博客:
霸道流氓气质的博客_CSDN博客-C#,架构之路,SpringBoot领域博主
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
1、使用http request组件请求json数据,请求地址
https://fchart.github.io/books.json
2、使用json解析组件解析,并选择JSON字符串与对象互转
3、输出选择第一个对象的title属性
4、效果
5、json数据
[
{
"id": "f4a4d8eab7935bc8",
"type": "tab",
"label": "流程 3",
"disabled": false,
"info": "",
"env": []
},
{
"id": "c428312d1f6165d1",
"type": "mqtt-broker",
"name": "mqtt",
"broker": "127.0.0.1",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
},
{
"id": "51eee50b4ec9422f",
"type": "ui_group",
"name": "dashboardDemo",
"tab": "29ae4c620f43ee0d",
"order": 1,
"disp": true,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "29ae4c620f43ee0d",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
},
{
"id": "a506c767a5c1edbd",
"type": "ui_base",
"theme": {
"name": "theme-light",
"lightTheme": {
"default": "#0094CE",
"baseColor": "#0094CE",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": true,
"reset": false
},
"darkTheme": {
"default": "#097479",
"baseColor": "#097479",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif",
"edited": false
},
"customTheme": {
"name": "Untitled Theme 1",
"default": "#4B7930",
"baseColor": "#4B7930",
"baseFont": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
},
"themeState": {
"base-color": {
"default": "#0094CE",
"value": "#0094CE",
"edited": false
},
"page-titlebar-backgroundColor": {
"value": "#0094CE",
"edited": false
},
"page-backgroundColor": {
"value": "#fafafa",
"edited": false
},
"page-sidebar-backgroundColor": {
"value": "#ffffff",
"edited": false
},
"group-textColor": {
"value": "#1bbfff",
"edited": false
},
"group-borderColor": {
"value": "#ffffff",
"edited": false
},
"group-backgroundColor": {
"value": "#ffffff",
"edited": false
},
"widget-textColor": {
"value": "#111111",
"edited": false
},
"widget-backgroundColor": {
"value": "#0094ce",
"edited": false
},
"widget-borderColor": {
"value": "#ffffff",
"edited": false
},
"base-font": {
"value": "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"
}
},
"angularTheme": {
"primary": "indigo",
"accents": "blue",
"warn": "red",
"background": "grey",
"palette": "light"
}
},
"site": {
"name": "Node-RED Dashboard",
"hideToolbar": "false",
"allowSwipe": "false",
"lockMenu": "false",
"allowTempTheme": "true",
"dateFormat": "DD/MM/YYYY",
"sizes": {
"sx": 48,
"sy": 48,
"gx": 6,
"gy": 6,
"cx": 6,
"cy": 6,
"px": 0,
"py": 0
}
}
},
{
"id": "248cbbb0.18e794",
"type": "ui_group",
"name": "MyGroup",
"tab": "3f79c420.cfc1bc",
"order": 1,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "3f79c420.cfc1bc",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
},
{
"id": "a0954be5.a7f7e8",
"type": "ui_group",
"name": "MyInput",
"tab": "3f79c420.cfc1bc",
"order": 2,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "ffb7767d.5ec0c8",
"type": "http request",
"z": "f4a4d8eab7935bc8",
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://fchart.github.io/books.json",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"senderr": false,
"x": 360,
"y": 180,
"wires": [
[
"77c6d060.4df97"
]
]
},
{
"id": "a7936a3e.034b98",
"type": "inject",
"z": "f4a4d8eab7935bc8",
"name": "",
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 210,
"y": 180,
"wires": [
[
"ffb7767d.5ec0c8"
]
]
},
{
"id": "77c6d060.4df97",
"type": "json",
"z": "f4a4d8eab7935bc8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 510,
"y": 180,
"wires": [
[
"80b292a2.4dcf5",
"5f300589.d8d4fc"
]
]
},
{
"id": "80b292a2.4dcf5",
"type": "debug",
"z": "f4a4d8eab7935bc8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload[0].title",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 200,
"wires": []
},
{
"id": "5f300589.d8d4fc",
"type": "debug",
"z": "f4a4d8eab7935bc8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload[0].id",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 140,
"wires": []
}
]
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/135995.html