net.minidev.json.parser.ParseException: неожиданный токен - PullRequest
0 голосов
/ 28 сентября 2018

В Джерси я пытаюсь использовать фильтр, чтобы получить информацию о запросах и ответах, а затем отправить их в очередь.Но я получил следующую ошибку:

net.minidev.json.parser.ParseException: Unexpected token 
com.api.core.ApiArrayResponse@66e6f184 at position 55.

Фильтр, который может получать информацию и преобразовывать ее в данные JSON

public void filter(ContainerRequestContext requestContext, 
ContainerResponseContext responseContext) {

System.out.println("filter start " + 
requestContext.getUriInfo().getPath());
   JSONObject jsonObject = new JSONObject();
   Map headers = requestContext.getHeaders();
   jsonObject.put("PathInfo", request.getPathInfo());
   jsonObject.put("HostName", request.getRemoteUser());
   jsonObject.put("requestHeader", headers);


   String res = responseContext.getEntity().toString();

   try {
       jsonObject.put("responseBody", JSONValue.parseStrict(res));


   } catch (net.minidev.json.parser.ParseException e) {

     e.printStackTrace();
  }

   if (requestContext.getUriInfo().getPath().equals("test")) {
       AuditQueue.queue.add(jsonObject.toJSONString());
   }
 }

И класс ApiArrayResponse

public class ApiArrayResponse<T> implements IApiResponse {

@HeaderParam(AddRequestIdFilter.API_TRACKING_ID)
public String request_id;


@XmlElement
public Collection<T> data;


@XmlElement
public PageInfo paging;

public ApiArrayResponse() { 
}


public ApiArrayResponse(Collection<T> data) {
  this.data = data;
}

public ApiArrayResponse(Collection<T> data, PageInfo pi) {
  this.data = data;
  this.paging = pi;
}

@Override
public void setRequestId(String requestId) {
  request_id = requestId;  
   }
}

Может кто-нибудь помочь мне выяснить, в чем проблема в моем коде и как ее исправить?Спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...