Example #1
0
        public static JObject BodyToJObject(RequestStream body)
        {
            body.Position = 0;
            JObject jsonObject = null;

            using (var memory = new MemoryStream())
            {
                try
                {
                    body.CopyTo(memory);
                    var str = Encoding.UTF8.GetString(memory.ToArray());
                    if (!string.IsNullOrEmpty(str))
                    {
                        jsonObject = JObject.Parse(str);
                    }
                }
                catch { }
            }

            return(jsonObject);
        }