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()); }
public final String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("lang", this.getLanguage().toString()); jb.appendObjectProperty("type", JavaId.typeToString(this.getType())); jb.appendObjectProperty("qname", this.getQualifiedName()); if(!this.annotations.isEmpty()) { jb.startArrayProperty("a"); for(String a: this.annotations) { jb.appendToArray(a); } jb.endArray(); } jb.endObject(); return jb.getJson(); }
public String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("tracedAt", StringUtil.formatDate(this.t)); jb.appendObjectProperty("count", new Integer(this.counter)); jb.appendObjectProperty("executionId", this.executionId); if(this.appContext!=null) jb.appendObjectProperty("app", JacksonUtil.asJsonString(this.appContext), false); if(this.archiveFileName!=null && this.archiveDigest!=null) { jb.appendObjectProperty("lib", this.archiveDigest); jb.appendObjectProperty("filename", this.archiveFileName); } if(this.junitContexts!=null && this.junitContexts.size()>0) { jb.startArrayProperty("junits"); for(ConstructId junit: this.junitContexts) jb.appendJsonToArray(junit.toJSON()); jb.endArray(); } //if(this.loader!=null) b.append(", \"loader\" : ").append(this.loader.toJSON()).append(""); jb.appendObjectProperty("constructId", c.toJSON(), false); jb.endObject(); return jb.toString(); } public void merge(ConstructUsage _other) {
final JsonBuilder json = new JsonBuilder().startObject(); json.startObjectProperty("workspace"); json.appendObjectProperty("token", a.getSpace().getSpaceToken()) .appendObjectProperty("name", a.getSpace().getSpaceName()); json.startArrayProperty("owners"); if(a.getSpace().getSpaceOwners()!=null && a.getSpace().getSpaceOwners().size()>0) { int i = 0; for(String o: a.getSpace().getSpaceOwners()) { json.appendToArray(o); json.endArray(); csv.append(separator); final String value = a.getSpace().getPropertyValue(p); csv.append(value==null?"":value).append(separator); json.appendObjectProperty(p, value); json.endObject(); json.startObjectProperty("app"); json.appendObjectProperty("id", a.getId().toString()) .appendObjectProperty("group", a.getMvnGroup()) .appendObjectProperty("artifact", a.getArtifact()) .appendObjectProperty("version", a.getVersion()); if(a.getCreatedAt()!=null) json.appendObjectProperty("createdAt", ApplicationExporterThread.DATE_FORMAT.format(a.getCreatedAt().getTime())); else json.appendObjectProperty("createdAt", (String)null);
/** * 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); }
public String getJson(boolean _pretty, String _indent) { if(!_pretty) return this.toString(); else { final String ugly = this.toString(); char c = 0; int i; case '{': indent_count++; pretty.append("{\n").append(this.indent(indent_count, _indent)); break; case '}': indent_count--; pretty.append("\n").append(this.indent(indent_count, _indent)).append("}"); break; case '[': else { indent_count++; pretty.append("[\n").append(this.indent(indent_count, _indent)); else { indent_count--; pretty.append("\n").append(this.indent(indent_count, _indent)).append("]"); pretty.append(c); else pretty.append(",\n").append(this.indent(indent_count, _indent)); break;
public String getJson() { return this.getJson(false, ""); }
/** * 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 String toJSON() { final StringBuilder b = new StringBuilder(); // Key information b.append("{"); b.append(" \"repo\" : \"").append(this.repo).append("\","); if(this.repoPath!=null) b.append(" \"repoPath\" : \"").append(this.repoPath).append("\","); b.append(" \"constructId\" : ").append(this.getConstruct().getId().toJSON()).append(","); if(this.commit!=null) b.append(" \"commit\" : \"").append(this.commit).append("\","); // Other information b.append(" \"constructChangeType\":\"").append(this.getType().toString()).append("\","); if(this.committedAt!=null) b.append(" \"committedAt\" : \"").append(StringUtil.formatDate(Long.parseLong(this.getCommittedAt()))).append("\""); // Buggy method body, fixed one and applied changes if(this.getType() == ConstructChangeType.MOD ){ if(this.fixSignature != null) //b.append(" \"description\" : ").append(JsonBuilder.escape(this.bugDescription)).append(", "); b.append(",\"fixedBody\":").append(JsonBuilder.escape(this.fixSignature.toJson().toString())); //b.append(getFixConstructASTSignature().toJson().toString()).append(" ,"); if(this.defSignature != null) b.append(",\"buggyBody\":").append(JsonBuilder.escape(this.defSignature.toJson().toString())); //b.append(getDefConstructASTSignature().toJson().toString()).append(" ,"); if(signatureChange != null) //b.append(" \"signatureChange\" : ").append(astDiff.toJSON().toString()).append(" ,"); //b.append("\"sigchg \" :[").append(JsonBuilder.escape(astDiff.toJSON().toString())).append("]").append(" ,"); b.append(",\"bodyChange\":").append(JsonBuilder.escape(signatureChange.toJSON().toString())); //b.append(astDiff.toJSON().toString()).append(" ,"); } b.append("}"); return b.toString(); }
@Override public String toJSON() { final JsonBuilder jb = new JsonBuilder(); jb.startObject(); jb.appendObjectProperty("lang", this.getLanguage().toString()); jb.appendObjectProperty("type", this.getSharedType().toString()); jb.appendObjectProperty("qname", this.getQualifiedName()); jb.endObject(); return jb.getJson(); } }
b.append(",\"goal\":\"").append(this.goalType).append("\""); b.append(",\"startedAtClient\":\"").append(StringUtil.formatDate(this.stopWatch.getStartMillis())).append("\""); b.append(",\"clientVersion\":").append(JsonBuilder.escape(CoreConfiguration.getVulasRelease())); b.append(",\"exception\":").append(JsonBuilder.escape(this.exception.getMessage().substring(0, Math.min(this.exception.getMessage().length(), 255)))); final String[] value = this.getConfiguration().getConfiguration().getStringArray("vulas." + key); if(c++>0) b.append(","); b.append("{\"source\":\"GOAL_CONFIG\",\"name\":").append(JsonBuilder.escape(key)).append(",\"value\":").append(JsonBuilder.escape(StringUtil.join(value, ","))).append("}"); for(Map.Entry<String, Double> entry: this.goalStats.entrySet()) { if(c++>0) b.append(","); b.append(JsonBuilder.escape(entry.getKey())).append(":").append(entry.getValue()); for(Map.Entry<String, String> entry: this.systemInfo.entrySet()) { if(c++>0) b.append(","); b.append("{\"source\":\"SYSTEM_INFO\",\"name\":").append(JsonBuilder.escape(entry.getKey())).append(",\"value\":").append(JsonBuilder.escape(entry.getValue())).append("}");
/** * 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; }