FourSquare API: 如何使用顶级类别 ID 获取特定类别?

FourSquare API: How to get specific categories using the top level category id?

我目前正在使用下面的端点

https://api.foursquare.com/v2/venues/categories?client_id=****&client_secret=****&v=20161222&m=foursquare

然后保存结果如下

JSONArray jsonArray = jsonObject.getJSONObject("response").getJSONArray("categories");

这为我提供了所有类别的列表,但我专门在食物中寻找那些 category.I 想使用食物 ID 4d4b7105d754a06374d81259 过滤掉类别。有什么方法可以从 JSONArray 做到这一点吗?

下面的代码描述了如何到达特定类别。遍历每个类别 ID,直到找到匹配项。

  try {
                JSONObject jsonObject = new JSONObject(result);
                if (jsonObject.has("response")) {

                    if (jsonObject.getJSONObject("response").has("categories")) {
                        JSONArray jsonArray = jsonObject.getJSONObject("response").getJSONArray("categories");


                        for (int i = 0; i < jsonArray.length(); i++) {

                            JSONObject eachCategory = jsonArray.getJSONObject(i);
                            eachID = eachCategory.getString("id");

                            //This is the food ID

                            if (eachID.equals("4d4b7105d754a06374d81259")) {