<commit_before>module Typertext.Json {
    import HttpRequest = Typertext.Http.HttpRequest;
    import HttpResponse = Typertext.Http.HttpResponse;
    import HttpResponseStatus = Typertext.Http.HttpResponseStatus;
    import HttpUrl = Typertext.Http.HttpUrl;
    import HttpPostData = Typertext.Http.HttpPostData;
    import HttpMethod = Typertext.Http.HttpMethod;

    export class JsonRequest implements Typertext.GenericRequest<JsonResponseHandler> {
        private jsonType:string;
        private request:HttpRequest;

        constructor(jsonContentType:string = "application/json") {
            this.request = new HttpRequest();
            this.jsonType = jsonContentType;
        }

        public Get(request:HttpUrl, callback:JsonResponseHandler):void {
            this.RawRequest(HttpMethod.GET, request, {}, callback);
        }

        public Post(request:HttpUrl, postData:HttpPostData, callback:JsonResponseHandler):void {
            this.RawRequest(HttpMethod.GET, request, postData, callback);
        }

        public RawRequest(method:Typertext.Http.HttpMethod, request:HttpUrl, postData:Typertext.Http.HttpPostData = {}, callback:JsonResponseHandler = (c)=> {
        }) {
            this.request.RawRequest(method, request, postData, (response:HttpResponse)=> {
                //Make sure that we got the Json content type we are expecting
                if (response.GetContentType() != this.jsonType) {
                    callback(new JsonResponse(HttpResponseStatus.responseError));
                }

                try {
                    callback(JsonResponse.fromHttpResponse(response));
                } catch (e) {
                    throw new JsonException("Json parse exception", -1);
                }
            });
        }
    }
}<commit_msg>Document JsonRequest<commit_after>/**
 * @namespace   Typertext
 * @module      Json
 */
module Typertext.Json {
    import HttpRequest = Typertext.Http.HttpRequest;
    import HttpResponse = Typertext.Http.HttpResponse;
    import HttpResponseStatus = Typertext.Http.HttpResponseStatus;
    import HttpUrl = Typertext.Http.HttpUrl;
    import HttpPostData = Typertext.Http.HttpPostData;
    import HttpMethod = Typertext.Http.HttpMethod;

    export class JsonRequest implements Typertext.GenericRequest<JsonResponseHandler> {
        private jsonType:string;
        private request:HttpRequest;

        /**
         * A class to simplify passing both the status and data of a completed proxy request
         *
         * @interface   GenericRequest
         * @uses        Typertext.Http.HttpRequest;
         * @uses        Typertext.Http.HttpResponse;
         * @uses        Typertext.Http.HttpResponseStatus;
         * @uses        Typertext.Http.HttpUrl;
         * @uses        Typertext.Http.HttpPostData;
         * @uses        Typertext.Http.HttpMethod;
         *
         * @author      <NAME> <<EMAIL>>
         * @version     0.3.0
         */
        constructor(jsonContentType:string = "application/json") {
            this.request = new HttpRequest();
            this.jsonType = jsonContentType;
        }

        /**
         * A convenience method for simply calling a GET
         *
         * @param   {HttpUrl}               request
         * @param   {JsonResponseHandler}   callback
         */
        public Get(request:HttpUrl, callback:JsonResponseHandler):void {
            this.RawRequest(HttpMethod.GET, request, {}, callback);
        }

        /**
         * A convenience method for simply calling a POST
         *
         * @param   {HttpUrl}               request
         * @param   {HttpPostData}          postData
         * @param   {JsonResponseHandler}   callback
         */
        public Post(request:HttpUrl, postData:HttpPostData, callback:JsonResponseHandler):void {
            this.RawRequest(HttpMethod.GET, request, postData, callback);
        }

        /**
         * A layer to automatically decode a response into a JSON object
         *
         * @param   {HttpMethod}            method
         * @param   {HttpUrl}               request
         * @param   {HttpPostData}          postData
         * @param   {JsonResponseHandler}   callback
         */
        public RawRequest(method:HttpMethod, request:HttpUrl, postData:Typertext.Http.HttpPostData = {}, callback:JsonResponseHandler = (c)=> {
        }) {
            this.request.RawRequest(method, request, postData, (response:HttpResponse)=> {
                //Make sure that we got the Json content type we are expecting
                if (response.GetContentType() != this.jsonType) {
                    callback(new JsonResponse(HttpResponseStatus.responseError));
                }

                try {
                    callback(JsonResponse.fromHttpResponse(response));
                } catch (e) {
                    throw new JsonException("Json parse exception", -1);
                }
            });
        }
    }
}
{'fraction_non_alphanumeric': 0.09136647212718857, 'fraction_numerical': 0.001006238679814852, 'mean_word_length': 2.0231143552311437, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3725392', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1239, 'n_words': 268}