Exemple #1
0
 public SPJsonArray(JsonKeyValueWriter json)
 {
     _json = json;
     _json.WriteStartArray();
 }
Exemple #2
0
 public SPJsonArray(JsonKeyValueWriter json, string name)
 {
     _json = json;
     _json.WritePropertyName(name);
     _json.WriteStartArray();
 }
Exemple #3
0
 public SPJsonObject(JsonKeyValueWriter json, string name)
 {
     _json = json;
     _json.WritePropertyName(name);
     _json.WriteStartObject();
 }
Exemple #4
0
 public SPJsonObject(JsonKeyValueWriter json)
 {
     _json = json;
     _json.WriteStartObject();
 }
Exemple #5
0
        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);
        }
Exemple #6
0
 public abstract void Jsonize(JsonKeyValueWriter jsonWriter);
Exemple #7
0
 public override void Jsonize(JsonKeyValueWriter jsonWriter)
 {
     jsonWriter.WriteKeyValue("Status", Status);
     jsonWriter.WriteKeyValue("Message", Message);
     jsonWriter.WriteKeyValue("StackTrace", StackTrace);
 }