我必须在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