public string ToJson() { StringBuilder sb = new StringBuilder(); sb.Append("\"edges\": {"); sb.Append("\"" + _sourceVertexType + "\": {\"" + _sourceVertexId + "\": {"); sb.Append("\"" + _edgeType + "\": {"); if (_attributes == null || _attributes.Count == 0) { sb.Append("\"" + _targetVertexType + "\":\"" + _targetVertexId + "\""); } else { sb.Append("\"" + _targetVertexType + "\": {\"" + _targetVertexId + "\""); sb.Append(": {" + _attributes.ToJson() + "}}"); } sb.Append("}}}}"); return(sb.ToString()); }
/// <summary> /// /// </summary> /// <param name="returnBodyOnly">If true - Does not contain the top element: ' "vertices": { ' (withoug the single quotes)</param> /// <returns></returns> public string ToJson(bool returnBodyOnly = false) { StringBuilder sb = new StringBuilder(); //sb.Append("\"vertices\": {"); //sb.Append("\"" + _vertextType + "\": {\"" + _vertextId + "\""); sb.Append("\"" + _vertextId + "\""); sb.Append(": {" + _attributes.ToJson() + "}"); //sb.Append("}"); if (returnBodyOnly) { return(sb.ToString()); } else { return("\"vertices\": {" + sb.ToString() + "}"); } }