Amqui, 石棉 ], 州:QC }, ] } ] 从JSON格式上面,我想得到所有国家名称,州名,城市名称的列表。 首先,我想要所有的国家名单。然后当我将国家名称作为加拿大传递时,应该获取其所有州,依此类推以获取相应国家,州和城市的城市名称。Hi All,I want to parse a JSON files which contains data in the format as shown below,[{"Country": "United States""States": [{"Cities": ["Abbeville","Abernant","Adamsville","Addison" ],"State": "AL"},{"Cities": ["Adak", "Akiak","Akutan", "Ambler" ],"State": "AK"}, ]},{"Country": "Canada""States": [{"Cities": ["Barrie","Belleville","Brampton", "Brant" ],"State": "ON"},{"Cities": ["Acton Vale","Alma","Amos","Amqui","Asbestos" ],"State": "QC"}, ]}]From above JSON format, I want to get list of all Country names, State names,City Names.First,I want all the country names list. Then when I pass country name as "Canada" then all its states should be fetched and so on to get the city names of respective country ,state and city.推荐答案请参阅: http://php.net/manual/en/book.json .php [ ^ ], http://php.net/manual/en/function.json-decode .php [ ^ ] 。 -SAPlease see:http://php.net/manual/en/book.json.php[^],http://php.net/manual/en/function.json-decode.php[^].—SA首先,将你的json数据读成一个字符串。First, read your json data into a string. strJson = file_get_contents(' data.json');strJson = file_get_contents('data.json'); 第二,解码jso n数据到数组变量Second, decode the json data into an array variable 这篇关于在php中解析JSON文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 10:34