jsoncouchdbektorp

JSON response from ektorp / couchdb


For client requests to ektorp / couchdb I would like to pass JSON back to the client. (Why not use couchdb direktly? Because I have to do some tweeks to the data on a Java layer inbetween.)

So is there for example a way to get JSON data from a CouchDbRepositorySupport queryView?


Solution

  • Here's another way:

    InputStream is = db.queryForStream(query);
    ObjectMapper mapper = new ObjectMapper();
    JsonNode json = mapper.readTree(is);
    

    (JsonNode and ObjectMapper are from the org.codehaus.jackson library.)