【发布时间】:2018-11-27 20:07:25
【问题描述】:
我正在尝试解析从以下链接检索到的 JSON 数据
http://fipeapi.appspot.com/api/1/carros/marcas.json
它没有 JsonArray 的名称。这是我到目前为止所尝试的。
private String getName(int position) {
String name = "";
try {
//Getting object of given index
JSONObject json = result.getJSONObject(position);
//Fetching name from that object
name = json.getString(Config.TAG_NAME);
} catch (JSONException e) {
e.printStackTrace();
}
//Returning the name
return name;
}
这是Config 类
public class Config {
//JSON URL
public static final String DATA_URL = "http://fipeapi.appspot.com/api/1/carros/marcas.json";
//Tags used in the JSON String
public static final String TAG_USERNAME = "name";
public static final String TAG_NAME = "fipe_name";
public static final String TAG_COURSE = "key";
public static final String TAG_ID_MARCA_CARRO = "id";
//JSON array name
public static final String JSON_ARRAY = "marcas";
}
如果您需要更多信息来帮助我解决此问题,请告诉我。提前致谢!
【问题讨论】:
-
我认为你应该检查这个stackoverflow.com/questions/4308554/… 或者这个链接中接受的答案正是你想要的stackoverflow.com/questions/13196234/…
标签: java json android-studio