/** * Appends an object property with the given name and value, whereby the value is escaped. * @param _property * @param _value * @return */ public JsonBuilder appendObjectProperty(String _property, String _value) { return this.appendObjectProperty(_property, _value, true); }
/** * Serializes the given object to JSON, thereby using no custom {@link StdSerializer}s. * @param _object * @return */ public static String asJsonString(final Object _object) { return JacksonUtil.asJsonString(_object, null); }
public String getJson() { return this.getJson(false, ""); }
public String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("id", this.id.toJSON(), false); jb.appendObjectProperty("cd", this.contentDigest); jb.endObject(); return jb.getJson(); } @Override
@Override public String toJson() { final JsonBuilder b = new JsonBuilder(); b.startObject(); b.appendObjectProperty("digest", this.digest); b.appendObjectProperty("digestAlgorithm", this.digestAlgorithm.toString()); b.appendObjectProperty("computedFrom", this.computedFrom); b.appendObjectProperty("computedFromType", this.computedFromType.toString()); b.endObject(); return b.toString(); }
public void checkValidity() throws JsonSyntaxException { JsonBuilder.checkJsonValidity(this.getJson()); }
/** * Reads the configuration setting vulas.backend.artifactMaps. * @return */ private static ArtifactMaps buildMaps(String _json) { ArtifactMaps maps = new ArtifactMaps(); if(_json!=null) { maps = (ArtifactMaps)JacksonUtil.asObject(_json, ArtifactMaps.class); } return maps; }
/** * Checks the syntax of the given JSON string. * @param _json * @return a JsonSyntaxException if there is a problem, null otherwise */ private static final Exception checkJson(String _json) { Exception exception = null; if(_json!=null) { try { JsonBuilder.checkJsonValidity(_json); } catch(JsonSyntaxException jse) { BasicHttpRequest.log.error("Invalid JSON syntax: " + jse.getMessage()); exception = jse; } } return exception; }
public JsonBuilder startArray() { this.fixComma(); b.append("["); this.openArrays++; return this; }
public void modifySpace(GoalContext _goal_context, Space _space) throws BackendConnectionException { final BasicHttpRequest r = new BasicHttpRequest(HttpMethod.PUT, PathBuilder.space(_space), null); r.setGoalContext(_goal_context); r.setPayload(JacksonUtil.asJsonString(_space), null, true); r.send(); }
/** * Appends an Integer to an already opened array. * @param _json * @return */ public JsonBuilder appendToArray(Integer _i) { this.fixComma(); this.b.append(_i); return this; }
public JsonBuilder startObject() { this.fixComma(); b.append("{"); this.openObjects++; return this; }
/** * Appends a self-contained JSON array or object to an already opened array. * @param _json * @return */ public JsonBuilder appendJsonToArray(String _json) { this.fixComma(); this.b.append(_json); return this; }
/** * Appends an object property with the given name and value. The value is escaped depending on the boolean parameter _escape. * @param _property * @param _value * @param _escape * @return */ public JsonBuilder appendObjectProperty(String _property, String _value, boolean _escape) { this.fixComma(); b.append(JsonBuilder.escape(_property)).append(":"); if(_value==null) b.append("null"); else if(_escape) b.append(JsonBuilder.escape(_value)); // else if(!this.isSelfContainedJson(_value)) // throw new JsonFormatException("Value is expected to be either a self-contained JSON array enclosed by [ and ], or object enclosed by { and }"); else b.append(_value); return this; }