我有来自JSONParser.java
try{
JSONArray postArray = jsonObject.getJSONArray("posts");
// Go through each post
for (int i = 0; i < postArray.length(); i++) {
JSONObject postObject = postArray.getJSONObject(i);
Post post = new Post();
post.setCfs(postObject.getJSONObject("custom_fields").optString("entity", "N/A"));
显示此
["Some text"]
我希望它在没有["
和"]
我的Json特定部分如下
"posts":[{
"date":"2016-02-10 10:28:42",
"categories":[{}],
"tags":[],
"author":{"name":"admin"},
"custom_fields":{
"ref_number":["ITB NUMBER: ITB\/002\/2016"],
"deadline":["26 February, 2016"],
"entity":["Refugees (xxx)"]
}
答案 0 :(得分:1)
似乎“实体”是数组,您应该尝试类似的东西:
post.setCfs(postObject.getJSONObject("custom_fields").optJSONArray("entity").getString(0));