避免从JSON数组响应中删除重复值

时间:2019-01-13 09:50:33

标签: android json android-volley

我有一组图像ID

  1005
  1003
  1001
  997
  994
  992
  983
  981
  979
  977
  975
  972
 1048
 1048
 857
 857
 817
 797
 1046
 751

当我要求提供这些ID时

http:/example.in/wp-json/wp/v2/media?per_page=50&orderby=include&include[]=1005&include[]=1157&include[]=1145&include[]=1140&include[]=1089&include[]=1085&include[]=857&include[]=1007&include[]=1005&include[]=1003&include[]=1001&include[]=997&include[]=994&include[]=992&include[]=983&include[]=981&include[]=979

JsonArray响应会删除重复ID,即1048和857,但我不想删除该ID,所以我该如何实现。

1 个答案:

答案 0 :(得分:0)

好吧,您在问如何添加要重复的值,但要使它们不相同,我认为这是后端问题,为避免这种情况,您需要将值推入php中的数组中:

array_push(values, 123);
array_push(values, 12);
array_push(values, 123);

响应将是:

[ 123, 12, 123 ]