@param JsonRpcCallResponse     $jsonRpcCallResponse
@param JsonRpcCall|null        $jsonRpcCall

@return string
166242
protected function getResponseString(
        JsonRpcCallResponse $jsonRpcCallResponse,
        JsonRpcCall $jsonRpcCall = null
    ) : string {
        $response = $this->jsonRpcCallSerializer->serialize($jsonRpcCallResponse);

        $event = new AcknowledgeEvent\OnResponseSendingEvent($response, $jsonRpcCallResponse, $jsonRpcCall);
        $this->dispatchJsonRpcEvent($event::EVENT_NAME, $event);

        return $response;
    }
14144
public function jsonSerialize() {
    $valid =
      (!isset($this->initialAlpha) ||
        $this->validateInitialAlpha($this->initialAlpha)) &&
      (!isset($this->initialScale) ||
        $this->validateInitialScale($this->initialScale));
    if (!$valid) {
      return NULL;
    }
    return parent::jsonSerialize();
  }
565066
protected function addEchoToJsonResponse(JsonResponse $r) {

		// handle JSON encoded request data
		
		if($this->isXhr && $this->xhrBag && $this->xhrBag->get('echo') == 1) {

			// echo is the original xmlHttpRequest sans echo property

			$echo = json_decode($this->xhrBag->get('xmlHttpRequest'));
			unset($echo->echo);

		}
		
		// handle plain POST or GET data
		
		else {

			if($this->request->getMethod() === 'POST' && $this->request->request->get('echo')) {
				$echo = $this->request->request->all();
				unset($echo['echo']);
			}

			else if($this->request->query->get('echo')) {
				$echo = $this->request->query->all();
				unset($echo['echo']);
			}

		}

		if(isset($echo)) {
			$r->setPayload([
				'echo'		=> $echo,
				'response'	=> json_decode($r->getContent())
			]);
		}
		
		return $r;

	}
725681
function JSON($object = null) {
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
		header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
		header("Cache-Control: no-cache, must-revalidate" ); 
		header("Pragma: no-cache" );
		header('Content-type: application/json');

		if (is_array($object)) {
			echo json_encode($object, $this->JSONOptions);
		} else if (is_bool($object)) {
			echo 0;
		} else if (is_string($object)) {
			echo $object;
		} else if (is_null($object)) {
			echo 'null';
		} else {
			die('Unknown object type to convert into JSON: ' . gettype($object));
		}

		if ($this->fatal)
			exit;
	}
1293143
def jsonrpc_map(self, request):
        
        result = "<h1>JSON-RPC map</h1><pre>{0}</pre>".format("\n\n".join([
            "{0}: {1}".format(fname, f.__doc__)
            for fname, f in self.dispatcher.items()
        ]))
        return HttpResponse(result)
1226602
private function getLastJsonResponse(): stdClass
    {
        if (null === ($decoded = json_decode($this->restContext->getMink()->getSession()->getDriver()->getContent()))) {
            throw new \RuntimeException('JSON response seems to be invalid');
        }

        return $decoded;
    }
1178661
private function getJsonRequest() {
        $request = $this->getRawPostData();
        if ($request == "") {
            throw new JsonRpcExeption(101, "Parse Error: no data");
        }
        $encoding = mb_detect_encoding($request, 'auto');
        if ($encoding != 'UTF-8') {
            $request = iconv($encoding, 'UTF-8', $request);
        }
        $request = json_decode($request);
        if ($request == NULL) { // parse error
            $error = $this->getJsonError();
            throw new JsonRpcExeption(101, "Parse Error: $error");
        }
        return $request;
    }
276811
public function handleJSONRequest( $jsonString ) {
		//Decode JSON string
		$jsonArray = json_decode($jsonString,true);
		if (!$jsonArray) return $this->resp(null,null,-32700,'Cannot Parse JSON');
		if (!isset($jsonArray['jsonrpc'])) return $this->resp(null,null,-32600,'No RPC version');
		if (($jsonArray['jsonrpc']!='2.0')) return $this->resp(null,null,-32600,'Incompatible RPC Version');
		//DO we have an ID to identify this request?
		if (!isset($jsonArray['id'])) return $this->resp(null,null,-32600,'No ID');
		//Fetch the request Identification String.
		$id = $jsonArray['id'];
		//Do we have a method?
		if (!isset($jsonArray['method'])) return $this->resp(null,$id,-32600,'No method');
		//Do we have params?
		if (!isset($jsonArray['params'])) {
			$data = array();
		}
		else {
			$data = $jsonArray['params'];
		}
		//Check method signature
		$method = explode(':',trim($jsonArray['method']));
		if (count($method)!=2) {
			return $this->resp(null, $id, -32600,'Invalid method signature. Use: BEAN:ACTION');
		}
		//Collect Bean and Action
		$beanType = $method[0];
		$action = $method[1];
		//May not contain anything other than ALPHA NUMERIC chars and _
		if (preg_match('/\W/',$beanType)) return $this->resp(null, $id, -32600,'Invalid Bean Type String');
		if (preg_match('/\W/',$action)) return $this->resp(null, $id, -32600,'Invalid Action String');

		try {
			switch($action) {
				case 'store':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean Object');
					$data = $data[0];
					if (!isset($data['id'])) $bean = RedBean_Facade::dispense($beanType); else
						$bean = RedBean_Facade::load($beanType,$data['id']);
					$bean->import( $data );
					$rid = RedBean_Facade::store($bean);
					return $this->resp($rid, $id);
				case 'load':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					return $this->resp($bean->export(),$id);
				case 'trash':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					RedBean_Facade::trash($bean);
					return $this->resp('OK',$id);
				case 'export':
					if (!isset($data[0])) return $this->resp(null, $id, -32602,'First param needs to be Bean ID');
					$bean = RedBean_Facade::load($beanType,$data[0]);
					$array = RedBean_Facade::exportAll(array($bean),true);
					return $this->resp($array,$id);
				default:
					$modelName = $this->modelHelper->getModelName( $beanType );
					if (!class_exists($modelName)) return $this->resp(null, $id, -32601,'No such bean in the can!');
					$beanModel = new $modelName;
					if (!method_exists($beanModel,$action)) return $this->resp(null, $id, -32601,"Method not found in Bean: $beanType ");
					return $this->resp( call_user_func_array(array($beanModel,$action), $data), $id);
			}
		}
		catch(Exception $exception) {
			return $this->resp(null, $id, -32099,$exception->getCode().'-'.$exception->getMessage());
		}
	}
237091
public function getCallable($methodName)
    {
        $this->checkMethodName($methodName);

        $class = $this->getClassName($methodName);
        $method = $this->getMethodName($methodName);

        $object = $this->createObject($class);

        if (!method_exists($object, $method)) {
            throw new JsonRpc\Exception\Method();
        }

        return array($object, $method);
    }
440858
function serialize($charset_encoding='')
		{
			// add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
			//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
			//{
				reset($this->me);
				list($typ, $val) = each($this->me);
				return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n";
			//}
		}
223269
public function jsonp($assoc = false, $fromEncoding = null, $toEncoding = 'UTF-8')
    {
        $jsonp = trim($this->body($fromEncoding, $toEncoding));
        if(isset($jsonp[0]) && $jsonp[0] !== '[' && $jsonp[0] !== '{') {
            $begin = strpos($jsonp, '(');
            if(false !== $begin)
            {
                $end = strrpos($jsonp, ')');
                if(false !== $end)
                {
                    $jsonp = substr($jsonp, $begin + 1, $end - $begin - 1);
                }
            }
        }
        return json_decode($jsonp, $assoc);
    }
1098078
public static function jsonToList($p_json)
    {
        $str = '';
        $arr = json_decode($p_json, true);
        foreach ($arr as $key => $value) {
            if ($str == '') {
                $str = $str . $key . '=' . $value;
            } else {
                $str = $str . ', ' . $key . '=' . $value;
            }
        }

        return $str;
    }
1220136
public function jsonSerialize() {
    $valid = (!isset($this->backgroundColor) ||
        $this->validateBackgroundColor($this->backgroundColor));
    if (!$valid) {
      return NULL;
    }
    return parent::jsonSerialize();
  }
125671
public static function makeFromJson(JsonResponse $json)
    {
        $content = $json->getContent();

        // If the contents of the JsonResponse does not starts with /**/ (typical laravel jsonp response)
        // we assume that it is a valid json response that can be decoded, or we just use the raw jsonp
        // contents for building the response
        if (! starts_with($json->getContent(), '/**/')) {
            $content = json_decode($json->getContent(), true);
        }

        $new = static::create($content, $json->getStatusCode());

        $new->headers = $json->headers;

        return $new;
    }
1067909
public function getJsonRpcResponseFromException(
        \Exception $exception,
        JsonRpcRequest $fromRequest = null
    ) : JsonRpcResponse {
        $event = new ActionEvent\OnExceptionEvent($exception, $fromRequest);
        $this->dispatchJsonRpcEvent($event::EVENT_NAME, $event);

        return $this->responseCreator->createErrorResponse($event->getException(), $fromRequest);
    }
565103
public static function decode($jsonString, $assoc = false)
    {
        $json = json_decode($jsonString, $assoc);

        self::handleError(json_last_error());

        return $json;
    }
491969
function (jsonSource) {
		var json = null;

		try {
			json = JSON.parse(jsonSource);
		} catch (err) {
			json = jsonSource; // string
		}

		return json;
	}