如何在json中找到并比较值?让我们说
{"data 1": {
"product": "54",
"info": {
"browser": "Safari",
"isp": "isp sample",
"width": 500,
"ip": 109.24.55.121,
"uid": 124,
"location": 10.23,123.90
}
}
{"data 2": {
"campaign": "2",
"info": {
"browser": "Mozilla",
"isp": "isp sample",
"width": 500,
"ip": 109.24.55.121,
"uid": 231,
"location": 10.23,123.90
}
}
{"data 3": {
"campaign": "2",
"info": {
"browser": "Mozilla",
"isp": "isp sample",
"width": 500,
"ip": 109.24.55.121,
"uid": 227,
"location": 10.23,123.90
}
}
{"same data": {
"campaign": "2",
"info": {
"browser": "Mozilla",
"isp": "isp sample",
"width": 500,
"ip": 109.24.55.121,
"uid": 227,
"location": 10.23,123.90
}
}
{"same data": {
"campaign": "2",
"info": {
"browser": "Mozilla",
"isp": "isp sample",
"width": 500,
"ip": 109.24.55.121,
"uid": 227,
"location": 10.23,123.90
}
}
我想输出有什么相似之处。什么字符串和什么值。
答案 0 :(得分:1)
$data = json_decode($your_json_data);
foreach($data as $datum) {
.... do some processing ...
}
json_encode / json_decode将在本机PHP数组和本机Javascript数组/对象之间进行转换。您没有说要处理哪种语言,但由于JSON IS javascript,因此无法在javascript端进行解码。只是加载数据然后去。在PHP上,您首先需要将其解码为本机PHP数组。