我必須在PHP中解析這個JSON,以便爲每個地址獲取地址,行和城市信息並將其存儲在數據庫中。我打算實施的方式是這樣的:使用有序密鑰後綴的PHP數組遍歷
For each key in the json string, check if it begins with address,
If yes, split the string based on '_' and get the index count.
Get line1, line2, city for this index count.
有沒有更好的方法來做到這一點?
(注意,索引數可以是隨機的)
{
"route": "A",
"address_0": "A0",
"line1_0": "L1_0",
"line2_0": "L2_0",
"city_0": "city_0",
"address_1": "A1",
"line1_1": "L1_1",
"line2_1": "L2_1",
"city_1": "city_1",
"address_2": "A2",
"line1_2": "L1_2",
"line2_2": "L2_2",
"city_2": "city_2",
}
的方式諸如PHP的內置[JSON擴展名](HTTP: //php.net/json_decode)? – Wiseguy