如何将android中的嵌套对象解析为可读的html

时间:2016-07-21 16:31:11

标签: android arrays json wordpress arraylist

我有来自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)"]
                }

1 个答案:

答案 0 :(得分:1)

似乎“实体”是数组,您应该尝试类似的东西:

post.setCfs(postObject.getJSONObject("custom_fields").optJSONArray("entity").getString(0));