Creates the main structure and returns the JSON response.
555424
def render_to_json(response, request=None, **kwargs):
    
    # determine the status code
    if hasattr(response, 'status_code'):
        status_code = response.status_code
    elif issubclass(type(response), Http404):
        status_code = 404
    elif issubclass(type(response), Exception):
        status_code = 500
        logger.exception(str(response), extra={'request': request})
        
        if settings.DEBUG:
            import sys
            reporter = ExceptionReporter(None, *sys.exc_info())
            text = reporter.get_traceback_text()
            response = HttpResponseServerError(text, content_type='text/plain')
        else:
            response = HttpResponseServerError("An error occured while processing an AJAX request.", content_type='text/plain')
    else:
        status_code = 200

    # creating main structure
    data = {
        'status': status_code,
        'statusText': REASON_PHRASES.get(status_code, 'UNKNOWN STATUS CODE'),
        'content': response
    }

    return JSONResponse(data, **kwargs)
553871
public function getJson()
    {
        $response = [
            'status' => $this->status,
        ];

        switch ($this->status) {
            case self::STATUS_SUCCESS:
            case self::STATUS_FAIL:
                $response = array_merge(
                    $response,
                    [
                        'data' => $this->data,
                    ]
                );
                break;
            case self::STATUS_ERROR;
                $code     = $this->code ? ['code' => $this->code] : [];
                $data     = $this->data ? ['data' => $this->data] : [];
                $response = array_merge(
                    $response,
                    [
                        'message' => $this->message,
                    ],
                    $code,
                    $data
                );
                break;
            default:
                // because of the check in setStatus, this should never occur
                $response = [
                    'status'  => self::STATUS_ERROR,
                    'code'    => 500,
                    'message' => 'JSend response was built illegally',
                    'data'    => [
                        'original-data' => [
                            'status'  => $this->status,
                            'code'    => $this->code,
                            'message' => $this->message,
                            'data'    => $this->data,
                        ],
                    ],
                ];
                break;
        }

        return json_encode($response);
    }
60844
def build_response(
            self,
            status=NOT_SET,
            error="",
            data=None):
        

        res_node = {
            "status": status,
            "error": error,
            "data": data
        }
        return res_node
281538
protected function createJsonResponse($data = null, $scope = null, $status = 200)
    {
        if ($data !== null) {
            $data = is_string($data) ?
                $data :
                $this->container->get('serializer')->serialize(
                    $data, 'json', empty($scope) ? array() : array('scope' => $scope)
                )
            ;
        }

        $response = new Response(null === $data ? '' : $data, $status);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
289997
def _create_json(self):
        
        data_json = {
            "rclass": "local",
            "key": self.name,
            "description": self.description,
            "packageType": self.packageType,
            "notes": "",
            "includesPattern": "**/*",
            "excludesPattern": "",
            "repoLayoutRef": self.repoLayoutRef,
            "dockerApiVersion": self.dockerApiVersion,
            "checksumPolicyType": "client-checksums",
            "handleReleases": True,
            "handleSnapshots": True,
            "maxUniqueSnapshots": 0,
            "snapshotVersionBehavior": "unique",
            "suppressPomConsistencyChecks": True,
            "blackedOut": False,
            "propertySets": [],
            "archiveBrowsingEnabled": self.archiveBrowsingEnabled,
            "yumRootDepth": 0,
        }
        return data_json
476749
def _as_json(self, **kwargs) -> str:
        
        return json.dumps(self, default=self._default, **kwargs)
746945
def output_json(data, code, headers=None):
    ''''''
    resp = make_response(json.dumps(data), code)
    resp.headers.extend(headers or {})
    return resp
315120
def to_json(self):
        """"""
        return {
            'location': self.location.to_json(),
            'design_days': [des_d.to_json() for des_d in self.design_days]
        }
1101601
def create_from_json(cls, json_data):
        
        block = Block()
        block_info = json_data["block_info"]
        block.block_id = block_info["block_id"]
        block.num_bins = block_info["num_bins"] if "num_bins" in block_info else None
        block.property_type = block_info["property_type"] if "property_type" in block_info else None
        block.meta = json_data["meta"] if "meta" in json_data else None

        block.component_results = _create_component_results(json_data, "block_info")

        return block
775196
def _json_request(self, method, path, data):
        

        response = self._request(method, path, data=data)
        _raise_for_status(response)
        if len(response.data) > 0:
            return _json_from_response(response)
        return response.data
803533
def to_json_basic(self):
        
        return {'name': self.__class__.__name__, 'priority': self.priority,
                'address': self.address, 'rtr': self.rtr}
935166
def json(self):
        
        _json = json.loads(self.reader)
        if _json.get('error', None):
            raise HTTPError(_json['error']['errors'])
        return _json
441322
private static JsonNode toJson(AggregatedHttpMessage res, @Nullable JsonNodeType expectedNodeType) {
        final String content = toString(res);
        final JsonNode node;
        try {
            node = Jackson.readTree(content);
        } catch (JsonParseException e) {
            throw new CentralDogmaException("failed to parse the response JSON", e);
        }

        if (expectedNodeType != null && node.getNodeType() != expectedNodeType) {
            throw new CentralDogmaException(
                    "invalid server response; expected: " + expectedNodeType +
                    ", actual: " + node.getNodeType() + ", content: " + content);
        }
        return node;
    }
511196
def json(self, start=None):
        
        if start is not None:
            data = self.data[start]
        return json.dumps(self.data, indent=4)
299689
function(){
            return {
                request: this.request.toJSON(),
                response: this.response.toJSON(),
                app: this.app.toJSON(),
                originalUrl: this.originalUrl,
                req: '<original node req>',
                res: '<original node res>',
                socket: '<original node socket>',
            };
        }
1164254
def _produce_instance(self, response):
        ''''''
        new_instance = self._stamp_out_core()
        # Post-process the response
        new_instance._local_update(response.json())

        # Allow for example files, which are KindTypeMismatches
        if hasattr(new_instance, 'selfLink'):
            if new_instance.kind != new_instance._meta_data[
                'required_json_kind'] \
                    and new_instance.kind != "tm:transaction:commandsstate" \
                    and 'example' not in new_instance.selfLink.split('/')[-1]:
                error_message = "For instances of type '%r' the corresponding" \
                                " kind must be '%r' but creation returned JSON with kind: %r" \
                                % (new_instance.__class__.__name__,
                                   new_instance._meta_data[
                                       'required_json_kind'],
                                   new_instance.kind)
                raise KindTypeMismatch(error_message)
        else:
            if new_instance.kind != new_instance._meta_data[
                'required_json_kind'] \
                    and new_instance.kind != "tm:transaction:commandsstate":
                error_message = "For instances of type '%r' the corresponding" \
                                " kind must be '%r' but creation returned JSON with kind: %r" \
                                % (new_instance.__class__.__name__,
                                   new_instance._meta_data[
                                       'required_json_kind'],
                                   new_instance.kind)
                raise KindTypeMismatch(error_message)

        # Update the object to have the correct functional uri.
        new_instance._activate_URI(new_instance.selfLink)
        return new_instance
489588
def to_json
      new_json = JSON.pretty_generate(@data)
      # nuke empty lines
      new_json = new_json.split("\n").reject(&:empty?).join("\n") + "\n"
      new_json
    end