java.lang.IllegalStateException:应为BEGIN_数组,但为BEGIN_对象Android错误
首先,我已经尝试了很多答案,比如: 还有更多 另外,我知道错误是我返回的是json对象而不是json数组 但是,仍然没有任何效果 我正在尝试在我的Android应用程序中获取WordPress博客帖子。我正在使用WordPress 5.2.1和WP REST API插件 yapi.javajava.lang.IllegalStateException:应为BEGIN_数组,但为BEGIN_对象Android错误,java,android,json,gson,retrofit2,Java,Android,Json,Gson,Retrofit2,首先,我已经尝试了很多答案,比如: 还有更多 另外,我知道错误是我返回的是json对象而不是json数组 但是,仍然没有任何效果 我正在尝试在我的Android应用程序中获取WordPress博客帖子。我正在使用WordPress 5.2.1和WP REST API插件 yapi.java public interface RetrofitArrayApi { @GET("wp-json/wp/v2/posts?per_page=100") Call<List<WPPost&g
public interface RetrofitArrayApi {
@GET("wp-json/wp/v2/posts?per_page=100")
Call<List<WPPost>> getPostInfo();
/// to make call to dynamic URL
// @GET
// Call<List<WPPost>> getPostInfo(@Url String url);
//
}
public class JsonApiDataModel {
@SerializedName("media_details")
MediaDetails mediaDetails;
public static String getSourceUrl(String json) {
return new Gson().fromJson(json, JsonApiDataModel.class).mediaDetails.sizes.full.sourceUrl;
}
public class MediaDetails {
@SerializedName("sizes")
Sizes sizes;
}
public class Sizes {
// you can use full, medium or thumbnail here!
@SerializedName("full")
Full full;
}
public class Full {
@SerializedName("source_url")
String sourceUrl;
}
}
public class Model {
public static final int IMAGE_TYPE =1;
public String title, subtitle, Image, date;
public int type;
public static final int TEXT_TYPE=0;
public String data;
public Model(int mtype, String mtitle, String msubtitle, String image, String mdate ){
this.title = mtitle;
this.date = mdate;
this.subtitle = msubtitle;
this.type = mtype;
this.Image = image;
}
public Model(int mtype){
this.type = mtype;
}
}
public class Blog extends Fragment {
private ProgressBar progressBar;
private String TAG ="BlogFragment";
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
private String baseURL = "https://www.myfitbytes.com/";
public static final SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public static List<WPPost> mListPost;
private boolean loading = true;
private int pastVisiblesItems, visibleItemCount, totalItemCount, PageCount=1, PageCountLock=0;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//LayoutInflater lf = getActivity().getLayoutInflater();
View view = lf.inflate(R.layout.fragment_blog, container, false);
//set fragment title
// getActivity().setTitle("Blog");
//wordpress blog posts
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
progressBar = (ProgressBar) view.findViewById(R.id.progressBarPosts);
mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
list = new ArrayList<Model>();
/// call retrofill
getRetrofit();
adapter = new RecyclerViewAdapter( list, getActivity());
recyclerView.setAdapter(adapter);
return view;
}
public void getRetrofit(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitArrayApi service = retrofit.create(RetrofitArrayApi.class);
Call<List<WPPost>> call = service.getPostInfo();
Log.e("hellooo", "Service = "+ service);
Log.e("hellooo", "retrofit = "+ retrofit);
Log.e("hellooo", "call = "+ call);
// to make call to dynamic URL
// String yourURL = yourURL.replace(BaseURL,"");
// Call<List<WPPost>> call = service.getPostInfo( yourURL);
/// to get only 6 post from your blog
// http://your-blog-url/wp-json/wp/v2/posts?per_page=2
// to get any specific blog post, use id of post
// http://www.blueappsoftware.in/wp-json/wp/v2/posts/1179
// to get only title and id of specific
// http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179?fields=id,title
call.enqueue(new Callback<List<WPPost>>() {
@Override
public void onResponse(Call<List<WPPost>> call, Response<List<WPPost>> response) {
Log.e("blog", " response "+ response.body());
mListPost = response.body();
progressBar.setVisibility(View.GONE);
for (int i=0; i<response.body().size();i++){
Log.e("main ", " title "+ response.body().get(i).getTitle().getRendered() + " "+
response.body().get(i).getId());
Log.e("main ", " HREF "+ response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref() + " "+
response.body().get(i).getId());
Log.e("main ", " Date "+ convertDateToTimeAgo(response.body().get(i).getDate()) + response.body().get(i).getDate().getClass().getSimpleName());
Log.e("Blog ","Category id or Name - " + response.body().get(i).getLink());
String tempdetails = response.body().get(i).getExcerpt().getRendered().toString();
tempdetails = tempdetails.replace("<p>","");
tempdetails = tempdetails.replace("</p>","");
tempdetails = tempdetails.replace("[…]","");
list.add( new Model( Model.IMAGE_TYPE, response.body().get(i).getTitle().getRendered(),
tempdetails,
response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref(),convertDateToTimeAgo(response.body().get(i).getDateGmt())));
}
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(Call<List<WPPost>> call, Throwable t) {
Log.e("hellooo", "inside onfail t = "+ t);
}
});
}
public static List<WPPost> getList(){
return mListPost;
}
//convert date
public String convertDateToTimeAgo(String time) {
String inputPattern = "yyyy-MM-dd'T'HH:mm:ss";
String outputPattern = "yyyy-MM-dd HH:mm:ss'Z'";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
inputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
outputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = null;
String str = null;
try {
date = inputFormat.parse(time);
str = outputFormat.format(date);
long dateInMilliSecond = System.currentTimeMillis() - date.getTime();
str = toDuration(dateInMilliSecond);
Log.e("Blog - ", "Date " + date);
Log.e("Blog - ", "Str " + str);
// Log.e("Blog - ", "dateInMilliSecond " + dateInMillinSecond);
} catch (ParseException e) {
e.printStackTrace();
}
return str;
}
public static final List<Long> times = Arrays.asList(
TimeUnit.DAYS.toMillis(365),
TimeUnit.DAYS.toMillis(30),
TimeUnit.DAYS.toMillis(1),
TimeUnit.HOURS.toMillis(1),
TimeUnit.MINUTES.toMillis(1),
TimeUnit.SECONDS.toMillis(1) );
public static final List<String> timesString = Arrays.asList("year","month","day","hour","minute","second");
public static String toDuration(long duration) {
StringBuffer res = new StringBuffer();
for(int i=0;i< times.size(); i++) {
Long current = times.get(i);
long temp = duration/current;
if(temp>0) {
res.append(temp).append(" ").append( timesString.get(i) ).append(temp != 1 ? "s" : "").append(" ago");
break;
}
}
if("".equals(res.toString()))
return "0 seconds ago";
else
return res.toString();
}
}
Model.java
public interface RetrofitArrayApi {
@GET("wp-json/wp/v2/posts?per_page=100")
Call<List<WPPost>> getPostInfo();
/// to make call to dynamic URL
// @GET
// Call<List<WPPost>> getPostInfo(@Url String url);
//
}
public class JsonApiDataModel {
@SerializedName("media_details")
MediaDetails mediaDetails;
public static String getSourceUrl(String json) {
return new Gson().fromJson(json, JsonApiDataModel.class).mediaDetails.sizes.full.sourceUrl;
}
public class MediaDetails {
@SerializedName("sizes")
Sizes sizes;
}
public class Sizes {
// you can use full, medium or thumbnail here!
@SerializedName("full")
Full full;
}
public class Full {
@SerializedName("source_url")
String sourceUrl;
}
}
public class Model {
public static final int IMAGE_TYPE =1;
public String title, subtitle, Image, date;
public int type;
public static final int TEXT_TYPE=0;
public String data;
public Model(int mtype, String mtitle, String msubtitle, String image, String mdate ){
this.title = mtitle;
this.date = mdate;
this.subtitle = msubtitle;
this.type = mtype;
this.Image = image;
}
public Model(int mtype){
this.type = mtype;
}
}
public class Blog extends Fragment {
private ProgressBar progressBar;
private String TAG ="BlogFragment";
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
private String baseURL = "https://www.myfitbytes.com/";
public static final SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public static List<WPPost> mListPost;
private boolean loading = true;
private int pastVisiblesItems, visibleItemCount, totalItemCount, PageCount=1, PageCountLock=0;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//LayoutInflater lf = getActivity().getLayoutInflater();
View view = lf.inflate(R.layout.fragment_blog, container, false);
//set fragment title
// getActivity().setTitle("Blog");
//wordpress blog posts
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
progressBar = (ProgressBar) view.findViewById(R.id.progressBarPosts);
mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
list = new ArrayList<Model>();
/// call retrofill
getRetrofit();
adapter = new RecyclerViewAdapter( list, getActivity());
recyclerView.setAdapter(adapter);
return view;
}
public void getRetrofit(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitArrayApi service = retrofit.create(RetrofitArrayApi.class);
Call<List<WPPost>> call = service.getPostInfo();
Log.e("hellooo", "Service = "+ service);
Log.e("hellooo", "retrofit = "+ retrofit);
Log.e("hellooo", "call = "+ call);
// to make call to dynamic URL
// String yourURL = yourURL.replace(BaseURL,"");
// Call<List<WPPost>> call = service.getPostInfo( yourURL);
/// to get only 6 post from your blog
// http://your-blog-url/wp-json/wp/v2/posts?per_page=2
// to get any specific blog post, use id of post
// http://www.blueappsoftware.in/wp-json/wp/v2/posts/1179
// to get only title and id of specific
// http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179?fields=id,title
call.enqueue(new Callback<List<WPPost>>() {
@Override
public void onResponse(Call<List<WPPost>> call, Response<List<WPPost>> response) {
Log.e("blog", " response "+ response.body());
mListPost = response.body();
progressBar.setVisibility(View.GONE);
for (int i=0; i<response.body().size();i++){
Log.e("main ", " title "+ response.body().get(i).getTitle().getRendered() + " "+
response.body().get(i).getId());
Log.e("main ", " HREF "+ response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref() + " "+
response.body().get(i).getId());
Log.e("main ", " Date "+ convertDateToTimeAgo(response.body().get(i).getDate()) + response.body().get(i).getDate().getClass().getSimpleName());
Log.e("Blog ","Category id or Name - " + response.body().get(i).getLink());
String tempdetails = response.body().get(i).getExcerpt().getRendered().toString();
tempdetails = tempdetails.replace("<p>","");
tempdetails = tempdetails.replace("</p>","");
tempdetails = tempdetails.replace("[…]","");
list.add( new Model( Model.IMAGE_TYPE, response.body().get(i).getTitle().getRendered(),
tempdetails,
response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref(),convertDateToTimeAgo(response.body().get(i).getDateGmt())));
}
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(Call<List<WPPost>> call, Throwable t) {
Log.e("hellooo", "inside onfail t = "+ t);
}
});
}
public static List<WPPost> getList(){
return mListPost;
}
//convert date
public String convertDateToTimeAgo(String time) {
String inputPattern = "yyyy-MM-dd'T'HH:mm:ss";
String outputPattern = "yyyy-MM-dd HH:mm:ss'Z'";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
inputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
outputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = null;
String str = null;
try {
date = inputFormat.parse(time);
str = outputFormat.format(date);
long dateInMilliSecond = System.currentTimeMillis() - date.getTime();
str = toDuration(dateInMilliSecond);
Log.e("Blog - ", "Date " + date);
Log.e("Blog - ", "Str " + str);
// Log.e("Blog - ", "dateInMilliSecond " + dateInMillinSecond);
} catch (ParseException e) {
e.printStackTrace();
}
return str;
}
public static final List<Long> times = Arrays.asList(
TimeUnit.DAYS.toMillis(365),
TimeUnit.DAYS.toMillis(30),
TimeUnit.DAYS.toMillis(1),
TimeUnit.HOURS.toMillis(1),
TimeUnit.MINUTES.toMillis(1),
TimeUnit.SECONDS.toMillis(1) );
public static final List<String> timesString = Arrays.asList("year","month","day","hour","minute","second");
public static String toDuration(long duration) {
StringBuffer res = new StringBuffer();
for(int i=0;i< times.size(); i++) {
Long current = times.get(i);
long temp = duration/current;
if(temp>0) {
res.append(temp).append(" ").append( timesString.get(i) ).append(temp != 1 ? "s" : "").append(" ago");
break;
}
}
if("".equals(res.toString()))
return "0 seconds ago";
else
return res.toString();
}
}
Blog.java
public interface RetrofitArrayApi {
@GET("wp-json/wp/v2/posts?per_page=100")
Call<List<WPPost>> getPostInfo();
/// to make call to dynamic URL
// @GET
// Call<List<WPPost>> getPostInfo(@Url String url);
//
}
public class JsonApiDataModel {
@SerializedName("media_details")
MediaDetails mediaDetails;
public static String getSourceUrl(String json) {
return new Gson().fromJson(json, JsonApiDataModel.class).mediaDetails.sizes.full.sourceUrl;
}
public class MediaDetails {
@SerializedName("sizes")
Sizes sizes;
}
public class Sizes {
// you can use full, medium or thumbnail here!
@SerializedName("full")
Full full;
}
public class Full {
@SerializedName("source_url")
String sourceUrl;
}
}
public class Model {
public static final int IMAGE_TYPE =1;
public String title, subtitle, Image, date;
public int type;
public static final int TEXT_TYPE=0;
public String data;
public Model(int mtype, String mtitle, String msubtitle, String image, String mdate ){
this.title = mtitle;
this.date = mdate;
this.subtitle = msubtitle;
this.type = mtype;
this.Image = image;
}
public Model(int mtype){
this.type = mtype;
}
}
public class Blog extends Fragment {
private ProgressBar progressBar;
private String TAG ="BlogFragment";
private ArrayList<Model> list;
private RecyclerViewAdapter adapter;
private RecyclerView recyclerView;
private LinearLayoutManager mLayoutManager;
private String baseURL = "https://www.myfitbytes.com/";
public static final SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
public static List<WPPost> mListPost;
private boolean loading = true;
private int pastVisiblesItems, visibleItemCount, totalItemCount, PageCount=1, PageCountLock=0;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//LayoutInflater lf = getActivity().getLayoutInflater();
View view = lf.inflate(R.layout.fragment_blog, container, false);
//set fragment title
// getActivity().setTitle("Blog");
//wordpress blog posts
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
progressBar = (ProgressBar) view.findViewById(R.id.progressBarPosts);
mLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
list = new ArrayList<Model>();
/// call retrofill
getRetrofit();
adapter = new RecyclerViewAdapter( list, getActivity());
recyclerView.setAdapter(adapter);
return view;
}
public void getRetrofit(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
RetrofitArrayApi service = retrofit.create(RetrofitArrayApi.class);
Call<List<WPPost>> call = service.getPostInfo();
Log.e("hellooo", "Service = "+ service);
Log.e("hellooo", "retrofit = "+ retrofit);
Log.e("hellooo", "call = "+ call);
// to make call to dynamic URL
// String yourURL = yourURL.replace(BaseURL,"");
// Call<List<WPPost>> call = service.getPostInfo( yourURL);
/// to get only 6 post from your blog
// http://your-blog-url/wp-json/wp/v2/posts?per_page=2
// to get any specific blog post, use id of post
// http://www.blueappsoftware.in/wp-json/wp/v2/posts/1179
// to get only title and id of specific
// http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179?fields=id,title
call.enqueue(new Callback<List<WPPost>>() {
@Override
public void onResponse(Call<List<WPPost>> call, Response<List<WPPost>> response) {
Log.e("blog", " response "+ response.body());
mListPost = response.body();
progressBar.setVisibility(View.GONE);
for (int i=0; i<response.body().size();i++){
Log.e("main ", " title "+ response.body().get(i).getTitle().getRendered() + " "+
response.body().get(i).getId());
Log.e("main ", " HREF "+ response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref() + " "+
response.body().get(i).getId());
Log.e("main ", " Date "+ convertDateToTimeAgo(response.body().get(i).getDate()) + response.body().get(i).getDate().getClass().getSimpleName());
Log.e("Blog ","Category id or Name - " + response.body().get(i).getLink());
String tempdetails = response.body().get(i).getExcerpt().getRendered().toString();
tempdetails = tempdetails.replace("<p>","");
tempdetails = tempdetails.replace("</p>","");
tempdetails = tempdetails.replace("[…]","");
list.add( new Model( Model.IMAGE_TYPE, response.body().get(i).getTitle().getRendered(),
tempdetails,
response.body().get(i).getLinks().getWpFeaturedmedia().get(0).getHref(),convertDateToTimeAgo(response.body().get(i).getDateGmt())));
}
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(Call<List<WPPost>> call, Throwable t) {
Log.e("hellooo", "inside onfail t = "+ t);
}
});
}
public static List<WPPost> getList(){
return mListPost;
}
//convert date
public String convertDateToTimeAgo(String time) {
String inputPattern = "yyyy-MM-dd'T'HH:mm:ss";
String outputPattern = "yyyy-MM-dd HH:mm:ss'Z'";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
inputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
outputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = null;
String str = null;
try {
date = inputFormat.parse(time);
str = outputFormat.format(date);
long dateInMilliSecond = System.currentTimeMillis() - date.getTime();
str = toDuration(dateInMilliSecond);
Log.e("Blog - ", "Date " + date);
Log.e("Blog - ", "Str " + str);
// Log.e("Blog - ", "dateInMilliSecond " + dateInMillinSecond);
} catch (ParseException e) {
e.printStackTrace();
}
return str;
}
public static final List<Long> times = Arrays.asList(
TimeUnit.DAYS.toMillis(365),
TimeUnit.DAYS.toMillis(30),
TimeUnit.DAYS.toMillis(1),
TimeUnit.HOURS.toMillis(1),
TimeUnit.MINUTES.toMillis(1),
TimeUnit.SECONDS.toMillis(1) );
public static final List<String> timesString = Arrays.asList("year","month","day","hour","minute","second");
public static String toDuration(long duration) {
StringBuffer res = new StringBuffer();
for(int i=0;i< times.size(); i++) {
Long current = times.get(i);
long temp = duration/current;
if(temp>0) {
res.append(temp).append(" ").append( timesString.get(i) ).append(temp != 1 ? "s" : "").append(" ago");
break;
}
}
if("".equals(res.toString()))
return "0 seconds ago";
else
return res.toString();
}
}
public类Blog扩展了片段{
私人ProgressBar ProgressBar;
私有字符串TAG=“BlogFragment”;
私有数组列表;
专用循环水适配器;
私人回收站;
私人直线酒店经理;
专用字符串baseURL=”https://www.myfitbytes.com/";
公共静态最终SimpleDataFormat inputFormat=新SimpleDataFormat(“yyyy-MM-dd'T'HH:MM:ss.SSS'Z'”);
公共静态列表;
私有布尔加载=真;
private int pastVisiblesItems,visibleItemCount,totalItemCount,PageCount=1,PageCountLock=0;
@可空
@凌驾
创建视图时的公共视图(LayoutFlater充气机、@Nullable ViewGroup容器、@Nullable Bundle savedInstanceState){
//LayoutInflater lf=getActivity().getLayoutInflater();
视图=左前充气(R.layout.fragment\u blog,容器,false);
//设置片段标题
//getActivity().setTitle(“博客”);
//wordpress博客帖子
recyclerView=(recyclerView)视图.findViewById(R.id.recycler\u视图);
progressBar=(progressBar)view.findViewById(R.id.progressBarPosts);
mLayoutManager=newlinearlayoutmanager(getActivity(),LinearLayoutManager.VERTICAL,false);
recyclerView.setLayoutManager(mLayoutManager);
列表=新的ArrayList();
///呼叫补发
getReformation();
适配器=新的RecycleServiceAdapter(列表,getActivity());
recyclerView.setAdapter(适配器);
返回视图;
}
公共空间更新(){
改装改装=新改装.Builder()
.baseUrl(baseUrl)
.addConverterFactory(GsonConverterFactory.create())
.build();
RefundationArrayAPI服务=Refundation.create(RefundationArrayAPI.class);
Call=service.getPostInfo();
Log.e(“helloo”,“Service=“+Service”);
Log.e(“hellooo”,“改装=”+改装);
Log.e(“helloo”,“call=“+call”);
//调用动态URL
//字符串yourURL=yourURL.replace(BaseURL,“”);
//Call=service.getPostInfo(您的URL);
///仅从您的博客中获取6篇文章
// http://your-blog-url/wp-json/wp/v2/posts?per_page=2
//要获取任何特定的博客帖子,请使用帖子id
// http://www.blueappsoftware.in/wp-json/wp/v2/posts/1179
//仅获取特定项目的标题和id
// http://www.blueappsoftware.in/android/wp-json/wp/v2/posts/1179?fields=id标题
call.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
Log.e(“blog”,“response”+response.body());
mListPost=response.body();
progressBar.setVisibility(View.GONE);
对于(int i=0;i0){
res.append(temp.append(“”).append(timestring.get(i)).append(temp!=1?“s”:“”).append(“ago”);
打破
}
}
如果(“.”等于(res.toString())
返回“0秒前”;
其他的
return res.toString();
}
}
正如我所提到的,大多数答案都建议删除“列表”,我确实这样做了,但没有起作用
谢谢,您的POJO中有一个错误,您需要接受为数组,但您正在接受为 对象。使用此结构希望对您有所帮助
private List<ClassName> responsekey;
private-List-responsekey;
使用站点从json响应生成正确的响应类发布你的WPPost类嘿…我重新生成了WPPost类,现在它可以工作了..也许WordPress 5有一些新内容请看我的答案是的,这就是答案。继续发布,这样我就可以将其标记为正确!我应该在哪里添加这一行?你需要在你的日志中添加这一行返回响应的位置