public SPJsonArray(JsonKeyValueWriter json) { _json = json; _json.WriteStartArray(); }
public SPJsonArray(JsonKeyValueWriter json, string name) { _json = json; _json.WritePropertyName(name); _json.WriteStartArray(); }
public SPJsonObject(JsonKeyValueWriter json, string name) { _json = json; _json.WritePropertyName(name); _json.WriteStartObject(); }
public SPJsonObject(JsonKeyValueWriter json) { _json = json; _json.WriteStartObject(); }
public override void ExecuteResult(ControllerContext context) { byte[] bytes = null; StringBuilder sb = new StringBuilder(); if (context == null) throw new ArgumentNullException("context"); HttpResponseBase response = context.HttpContext.Response; if (!string.IsNullOrEmpty(this.ContentType)) response.ContentType = this.ContentType; else response.ContentType = "application/json"; if (this.ContentEncoding != null) response.ContentEncoding = this.ContentEncoding; if (this.Data == null) { using (JsonKeyValueWriter jWriter = new JsonKeyValueWriter(sb)) using (SPJsonObject jObject = new SPJsonObject(jWriter)) { jObject.Add("Status", 1 ); } } else if (this.Data.GetType() == typeof(PureJson)) { sb = ((PureJson)this.Data).StringBuilder; } else if (this.Data.GetType() == typeof(String)) { using (JsonKeyValueWriter jWriter = new JsonKeyValueWriter(sb)) using (SPJsonObject jObject = new SPJsonObject(jWriter)) { jObject.Add("Status", 0); jObject.Add("Data", this.Data); } } bytes = response.ContentEncoding.GetBytes(sb.ToString()); response.OutputStream.Write(bytes, 0, bytes.Length); }
public abstract void Jsonize(JsonKeyValueWriter jsonWriter);
public override void Jsonize(JsonKeyValueWriter jsonWriter) { jsonWriter.WriteKeyValue("Status", Status); jsonWriter.WriteKeyValue("Message", Message); jsonWriter.WriteKeyValue("StackTrace", StackTrace); }