I am developing Android application where I need to get posts from Wordpress blog (with specific tag).
plugin is installed: <a href="https://wordpress.org/plugins/json-api/" rel="nofollow noreferrer">https://wordpress.org/plugins/json-api/</a>
In my application I use Volley library. I am getting this error:
My code:
Could someone help me and tell what do I need to change in order to make it work?
Code:
JSON API
In my application I use Volley library. I am getting this error:
Code:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT
My code:
Code:
String url = " http://christianconcepts.com/api/get_tag_posts/?tag_slug=appcontent ";
ListView postList;
List<Object> list;
Gson gson;
Map<String,Object> mapPost;
Map<String,Object> mapTitle;
String postTitle[];
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
gson = new Gson();
list = (List) gson.fromJson(s, List.class); // error line
postTitle = new String[list.size()];
for(int i=0;i<list.size();++i){
mapPost = (Map<String,Object>)list.get(i);
mapTitle = (Map<String, Object>) mapPost.get("title");
postTitle[i] = (String) mapTitle.get("rendered");
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(getActivity().getApplicationContext(), "Some error occurred", Toast.LENGTH_LONG).show();
}
});
RequestQueue rQueue = Volley.newRequestQueue(myView.getContext());
rQueue.add(request);
Could someone help me and tell what do I need to change in order to make it work?