我是Json文件的新手。我想问一个关于如何从我的json文件中检索单个数据的问题,如
"common.ALLTYPES_HASHED_LEGACY_BLOB": [75,0,0,0,242,57,95,229,91,72,205,100,56]
我如何从我的json文件中获取该单个值?
这是我的Json文件:
{
"result": {
"common.ALLTYPES_NAME": "",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
68,
114,
105
],
"_datalogger": [
{
"common.ALLTYPES_NAME": "_DataLogger",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
2,
0,
0,
0,
93,
130,
13,
199
],
"log_groups": [
{
"common.ALLTYPES_NAME": "Datalog",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
164,
0,
0,
0,
133,
183,
237,
140,
108
],
"table_aliases": [
{
"common.ALLTYPES_NAME": "__internal",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
75,
0,
0,
0,
242,
57,
95,
229,
91,
72,
205,
100,
56
]
}
],
"triggers": [
{
"common.ALLTYPES_NAME": "Trigger",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
109,
0,
0,
0,
85,
151,
173,
242
]
}
],
"log_items": [
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM01_Speed",
"common.ALLTYPES_DESCRIPTION": ""
},
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM02_Speed",
"common.ALLTYPES_DESCRIPTION": ""
},
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM04_Speed",
"common.ALLTYPES_DESCRIPTION": ""
}
]
}
]
}
]
}
}
答案 0 :(得分:0)
以下是一个例子:
$var = '{
"result": {
"common.ALLTYPES_NAME": "",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
68,
114,
105
],
"_datalogger": [
{
"common.ALLTYPES_NAME": "_DataLogger",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
2,
0,
0,
0,
93,
130,
13,
199
],
"log_groups": [
{
"common.ALLTYPES_NAME": "Datalog",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
164,
0,
0,
0,
133,
183,
237,
140,
108
],
"table_aliases": [
{
"common.ALLTYPES_NAME": "__internal",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
75,
0,
0,
0,
242,
57,
95,
229,
91,
72,
205,
100,
56
]
}
],
"triggers": [
{
"common.ALLTYPES_NAME": "Trigger",
"common.ALLTYPES_DESCRIPTION": "",
"common.ALLTYPES_HASHED_LEGACY_BLOB": [
109,
0,
0,
0,
85,
151,
173,
242
]
}
],
"log_items": [
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM01_Speed",
"common.ALLTYPES_DESCRIPTION": ""
},
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM02_Speed",
"common.ALLTYPES_DESCRIPTION": ""
},
{
"common.ALLTYPES_NAME": "Scada 3 Channel.ScadaDevice1.WM04_Speed",
"common.ALLTYPES_DESCRIPTION": ""
}
]
}
]
}
]
}
}';
$res = json_decode($var, true);
print_r( $res['result']['_datalogger'][0]['log_groups'][0]['table_aliases'][0]['common.ALLTYPES_HASHED_LEGACY_BLOB'][0] );