/** * @param Will be JSON-encoded. * @return the view query for chained calls */ public ViewQuery endKey(Object o) { reset(); try { endKey = mapper.writeValueAsString(o); } catch (Exception e) { throw Exceptions.propagate(e); } return this; }
public String toJson(ObjectMapper mapper) { ObjectNode rootNode = mapper.createObjectNode(); ArrayNode keysNode = rootNode.putArray("keys"); for (Object key : keys) { keysNode.addPOJO(key); } try { return mapper.writeValueAsString(rootNode); } catch (Exception e) { throw Exceptions.propagate(e); } }
private DesignDocument.View loadViewFromFile( Map<String, DesignDocument.View> views, View input, Class<?> repositoryClass) { try { InputStream in = repositoryClass.getResourceAsStream(input.file()); if (in == null) { throw new FileNotFoundException("Could not load view file with path: " + input.file()); } String json = IOUtils.toString(in, "UTF-8"); return mapper().readValue(json.replaceAll("\n", ""), DesignDocument.View.class); } catch (Exception e) { throw Exceptions.propagate(e); } }