Neero
Neero

Reputation: 226

"invalid char in json text" error in Couchbase view results

This is the my document which i store in the bucket.Also the Id(key) attribute is screenName.

{
       "created": null,
       "createdBy": null,
       "updated": null,
       "updatedBy": null,
       "screenName": "steelers",
       "appId": "100",
       "domain": "100$APPINFOTEAM",
       "alias": "steelers",
       "devision": "1"
   }

I have multiple documents in Couchbase in this format. So i need to fetch these documents in descending order. So this is the implementation I used it for,

        Query query = new Query();
        // Filter on the domain key
        query.setIncludeDocs(true);
        query.setDescending(true);
        query.setInclusiveEnd(true);
        query.setKey(domain);
        List<AppInfoTeam> appInfoTeam = appinfoTeamService.getAppInfoTeamForApp(query);

This will give me the exact documents without sorting. This is my view

function (doc, meta) {
if (doc._class == "com.link.twitter.pojo.AppInfoTeam") {
    emit(doc.domain, null);
  }
}

Also I tried to Filter Results using Couchbase server interface. I tick the descending and inclusive_end values. Also put the domain as a key. Then when I click the show results button it will give me this error.

url: ?stale=false&descending=true&inclusive_end=true&key=domain&connection_timeout=60000&limit=10&skip=0

Error:

{"error":"bad_request","reason":"invalid UTF-8 JSON: {{error,{1,\"lexical error: invalid char in json text.\\n\"}},\n                     \"domain\"}"}

How can I fix this issue?

Upvotes: 1

Views: 626

Answers (1)

FuzzyAmi
FuzzyAmi

Reputation: 8109

You need to wrap the key with double quotes:

<url>?stale=false&descending=true&inclusive_end=true&key="domain"&connection_timeout=60000&limit=10&skip=0

Upvotes: 4

Related Questions