Restlet throwing error when JSON begins with [



我正在使用 Restlet 来使用 json 网络服务,但收到此错误:

A JSONObject text must begin with '{' at character 1

我得到的 json 响应以 [ 开头,这似乎是导致问题的原因。

有没有办法解决这个问题?

这是我的代码:

ClientResource resource = new ClientResource(
    "https://api.prosper.com/api/Listings?$top=3");
resource.setChallengeResponse(
    ChallengeScheme.HTTP_BASIC, "username", "password");
Representation representation = resource.get();
JsonRepresentation jsonRepresentation = new JsonRepresentation(representation);
JSONObject jsonObject = jsonRepresentation.getJsonObject();

[开头的 JSON 是一个 json 数组。以 { 开头的 JSON 是一个 json 对象。

使用JsonRepresentation#getJsonArray()

JSONArray jsonArray = jsonRepresentation.getJsonArray();

在继续之前,请熟悉json格式。

最新更新