"{ "code": 0, "msg": "success", "data": { "id": 22, "createdAt": "2023-06-12T09:58:49.141+08:00", "updatedAt": "2023-06-12T09:58:49.145+08:00", "deletedAt": null, "pipeID": "L0133028200000022", "xCoor": 4.5, "yCoor": 9, "name": "", "systemID": "1", "pipeCategory": 0, "pipeLength": 0, "roadName": "", "inJuncID": "P073302820000001", "outJuncID": "A023302820000001", "inElev": 0, "outElev": 0, "shapeType": 0, "invertSilphon": 0, "shapeData1": 0, "shapeData2": 0, "shapeData3": 0, "shapeData4": 0, "shapeXYData": 0, "material": 0, "otherMaterial": "", "roughness": 0, "dataSource": 0, "otherSource": "", "reportUnit": "", "pressureType": 0, "wallThickness": 0, "linerMaterial": 0, "linerThickness": 0, "jointType": 0, "connType": 0, "pipeSlope": 0, "ownership": 0, "shapeArea": 0, "selfWashing": 0, "rainSewaMix": 0, "originStruct": 0, "constrMethod": 0, "trenchlessMethod": 0, "status": 0, "remark": "", "diameter": 0, "flowDir": 0, "pipeClass": 0, "pipeClassOther": "", "points": "[[121.291165,30.173354],[121.289325,30.1733],[121.289145,30.172799],[121.288794,30.172484],[121.287953,30.169528],[121.291075,30.169468]]", "code": "330282000000" } }"GO取出id,xcoor,ycoor的值
时间: 2023-07-08 18:55:40 浏览: 129
可以使用以下代码来获取id、xCoor和yCoor的值:
```
import json
data = '{ "code": 0, "msg": "success", "data": { "id": 22, "createdAt": "2023-06-12T09:58:49.141+08:00", "updatedAt": "2023-06-12T09:58:49.145+08:00", "deletedAt": null, "pipeID": "L0133028200000022", "xCoor": 4.5, "yCoor": 9, "name": "", "systemID": "1", "pipeCategory": 0, "pipeLength": 0, "roadName": "", "inJuncID": "P073302820000001", "outJuncID": "A023302820000001", "inElev": 0, "outElev": 0, "shapeType": 0, "invertSilphon": 0, "shapeData1": 0, "shapeData2": 0, "shapeData3": 0, "shapeData4": 0, "shapeXYData": 0, "material": 0, "otherMaterial": "", "roughness": 0, "dataSource": 0, "otherSource": "", "reportUnit": "", "pressureType": 0, "wallThickness": 0, "linerMaterial": 0, "linerThickness": 0, "jointType": 0, "connType": 0, "pipeSlope": 0, "ownership": 0, "shapeArea": 0, "selfWashing": 0, "rainSewaMix": 0, "originStruct": 0, "constrMethod": 0, "trenchlessMethod": 0, "status": 0, "remark": "", "diameter": 0, "flowDir": 0, "pipeClass": 0, "pipeClassOther": "", "points": "[[121.291165,30.173354],[121.289325,30.1733],[121.289145,30.172799],[121.288794,30.172484],[121.287953,30.169528],[121.291075,30.169468]]", "code": "330282000000" } }'
parsed_data = json.loads(data)
id_val = parsed_data['data']['id']
xcoor_val = parsed_data['data']['xCoor']
ycoor_val = parsed_data['data']['yCoor']
print(f"id: {id_val}, xCoor: {xcoor_val}, yCoor: {ycoor_val}")
```
输出结果为:
```
id: 22, xCoor: 4.5, yCoor: 9
```
阅读全文