private ObjectNode getNewPointJson( String name, String opening_hours, double latitude, double longitude) { ObjectNode newPoint = Json.newObject(); newPoint.put("name", name); newPoint.put("opening_hours", opening_hours); newPoint.putObject("location").put("lat", latitude).put("lon", longitude); return newPoint; }
@Override public String toBulkJson(final ObjectNode node) { ObjectNode index = node.putObject("delete"); index.put("_index", this.index); index.put("_type", type); index.put("_id", id); return node.toString(); }
protected void sendError(int code, String message) throws IOException { ObjectNode root = this.mapper.createObjectNode(); root.put(TYPE, ERROR); ObjectNode data = root.putObject(ERROR); data.put(TYPE, PROGRAMMER); data.put(CODE, code); data.put(MESSAGE, message); this.connection.sendMessage(this.mapper.writeValueAsString(root)); }
/* * Protocol Specific Abstract Functions */ @Override public void sendStatus(int CV, int value, int status) throws IOException { log.debug("sendStatus called for CV {} with value {} and status {}", CV, value, status); if (status == ProgListener.OK) { ObjectNode root = this.mapper.createObjectNode(); root.put(TYPE, PROGRAMMER); ObjectNode data = root.putObject(DATA); data.put(NODE_CV, CV); data.put(VALUE, value); data.put(STATE, status); this.connection.sendMessage(this.mapper.writeValueAsString(root)); } else { this.sendError(416, Bundle.getMessage(this.connection.getLocale(), "ErrorProgrammer416")); } }
@Override public void setPower(int v) throws JmriException { this.power = PowerManager.UNKNOWN; // while waiting for reply ObjectNode root = this.trafficController.mapper.createObjectNode(); root.put(JSON.TYPE, JSON.POWER); ObjectNode data = root.putObject(JSON.DATA); switch (v) { case PowerManager.OFF: data.put(JSON.STATE, JSON.OFF); break; case PowerManager.ON: data.put(JSON.STATE, JSON.ON); break; default: data.put(JSON.STATE, JSON.UNKNOWN); break; } this.trafficController.sendJsonClientMessage(new JsonClientMessage(root), this); this.firePropertyChange(PowerManager.POWER, null, null); }
private ObjectNode getCafeInfoJson(float last_rating, String user_id, String user_name) { ObjectNode cafeInfo = Json.newObject(); cafeInfo.put("last_rating", last_rating); cafeInfo.putObject("added_by").put("user_id", user_id).put("user_name", user_name); return cafeInfo; }
public JSONResult(final @NonNull String errorMessage) { isSuccess = false; data = new ObjectNode(JsonUtils.factory); data.putObject("error").put("developer_message", errorMessage); }