Exemplo n.º 1
0
        protected internal virtual object ParseJSONResponse(HttpURLConnection conn)
        {
            Object      result    = null;
            var         stream    = conn.GetOutputStream();
            var         bytesRead = 0L;
            const Int32 chunkSize = 8192;

            var bytes = stream.ReadAllBytes();

            var responseBody = new Body(bytes);

            if (responseBody != null)
            {
                var    json       = responseBody.GetJson();
                String jsonString = null;
                if (json != null)
                {
                    jsonString = Sharpen.Runtime.GetStringForBytes(json);
                    try
                    {
                        result = mapper.ReadValue <object>(jsonString);
                    }
                    catch (Exception)
                    {
                        Assert.Fail();
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        protected internal virtual object ParseJSONResponse(URLConnection conn)
        {
            object result       = null;
            Body   responseBody = conn.GetResponseBody();

            if (responseBody != null)
            {
                byte[] json       = responseBody.GetJson();
                string jsonString = null;
                if (json != null)
                {
                    jsonString = Sharpen.Runtime.GetStringForBytes(json);
                    try
                    {
                        result = mapper.ReadValue <object>(jsonString);
                    }
                    catch (Exception)
                    {
                        Fail();
                    }
                }
            }
            return(result);
        }