从php://input读取json格式的数据并添加到请求中.
420167
public function addJsonPostBody() {
        $rqMethod = strtolower(isset($_SERVER ['REQUEST_METHOD']) ? $_SERVER ['REQUEST_METHOD'] : 'get');
        if ($rqMethod == 'post' || $rqMethod == 'put') {
            //检测请求头
            $contentType = '';
            // Look for the content type header
            if (isset ($_SERVER ["HTTP_CONTENT_TYPE"])) {
                $contentType = $_SERVER ["HTTP_CONTENT_TYPE"];
            } else if (isset ($_SERVER ["CONTENT_TYPE"])) {
                $contentType = $_SERVER ["CONTENT_TYPE"];
            }
            if (strpos($contentType, '/json') > 0) {
                $postData = @file_get_contents('php://input');
                if ($postData) {
                    $postData = @json_decode($postData, true);
                    if ($postData) {
                        $this->addUserData($postData);
                    }
                }
            }
        }
    }
1300718
def json(self, **kwargs):
        """"""
        encoding = detect_encoding(self.content[:4])
        value = self.content.decode(encoding)

        return simplejson.loads(value, **kwargs)
526129
private static function getParsedInput()
    {
        $input = file_get_contents('php://input') ?: null;

        switch (self::getContentType()) {
            case 'application/atom+xml':
                $input = new \SimpleXmlElement($input);
                break;
            case 'text/html':
            case 'text/plain':
            case 'application/json':
            case 'application/javascript':
                $input = json_decode($input, true);
                break;
            case 'multipart/form-data':
            case 'application/x-www-form-urlencoded':
                $data = [];
                self::parseRaw($input, $data);
                $input = $data;
                break;
        }

        return $input ?? [];
    }
291759
protected function _readInput()
    {
        if (empty($this->_input)) {
            $fh = fopen('php://input', 'rb');
            $content = stream_get_contents($fh);
            fclose($fh);
            $this->_input = $content;
        }

        return $this->_input;
    }
595999
def put_json(self, url, data, cls=None, **kwargs):
        
        kwargs['data'] = to_json(data, cls=cls)
        kwargs['headers'] = self.default_headers
        return self.put(url, **kwargs).json()
269738
public function input($file_content)
    {
        $this->file_content = $file_content;

        $this->parsed_content = json_decode($this->file_content, true);
    }
985568
protected function prepareInput()
    {
        if ($this->input instanceof Bag) {
            return;
        }

        $input = array();

        if ($_SERVER['REQUEST_METHOD'] == "POST") {

            $xmlInput = file_get_contents('php://input');

            $array = XML::parse($xmlInput);

            if (isset($array['Encrypt'])) {
                $this->encryptStr = $array['Encrypt'];
            }

            $input = $this->getCrypt()->decryptMsg(
                    $_REQUEST['msg_signature'],
                    $_REQUEST['nonce'],
                    $_REQUEST['timestamp'],
                    $xmlInput
                );
        }

        $this->input = new Bag(array_merge($_REQUEST, (array) $input));

    }
552023
def input(self, _in, out, **kwargs):
        """"""
        language_code = _re_language_code.search(_in.read()).group(
            'language_code'
        )
        _in.seek(0)  # move at the begining after matching the language
        catalog = read_po(_in)
        out.write('gettextCatalog.setStrings("{0}", '.format(language_code))
        out.write(json.dumps({
            key: value.string for key, value in catalog._messages.items()
            if key and value.string
        }))
        out.write(');')
1272995
private function parsePut()
    {
        $contentType = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : 'application/x-www-form-urlencoded';

        $tmp = explode(';', $contentType);
        $boundary = '';
        $encoding = '';

        $contentType = array_shift($tmp);

        foreach ($tmp as $t) {
            if (strpos($t, 'boundary') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $boundary = '--' . $t[1];
                }
            } elseif (strpos($t, 'charset') !== false) {
                $t = explode('=', $t, 2);
                if (isset($t[1])) {
                    $encoding = $t[1];
                }
            }
            if ($boundary !== '' && $encoding !== '') {
                break;
            }
        }

        switch ($contentType) {
            case 'multipart/form-data':
                #grab multipart boundary from content type header
                if (!empty($boundary)) {
                    break;
                }
                $contentType = 'application/x-www-form-urlencoded';
            // Fallthrough intentional - no boundary supplied with multipart content-type, so treat as url encoded
            case 'application/x-www-form-urlencoded':
                parse_str(file_get_contents($this->unitTestRequestFile ?: 'php://input'), $_POST);
                return;
            default:
                return;
        }

        $_FILES = [];
        $_POST = [];
        $chunkLength = 8096;
        $raw_headers = '';

        $stream = fopen($this->unitTestRequestFile ?: 'php://input', 'rb');

        $sanity = fgets($stream, strlen($boundary) + 5);

        // Skip initial blank line
        if ($sanity == "\r\n") {
            $sanity = fgets($stream, strlen($boundary) + 5);
        }

        if (rtrim($sanity) !== $boundary) {
            #malformed file, boundary should be first item
            return;
        }

        while (($chunk = fgets($stream)) !== false) {
            if ($chunk === $boundary) {
                continue;
            }

            if (rtrim($chunk) == '') { #blank line means we have all the headers and are going to read content
                $raw_headers = explode("\r\n", $raw_headers);
                $headers = [];
                $matches = [];

                foreach ($raw_headers as $header) {
                    if (strpos($header, ':') === false) {
                        continue;
                    }
                    list($name, $value) = explode(':', $header, 2);
                    $headers[strtolower($name)] = ltrim($value, ' ');
                }

                $raw_headers = '';

                if (!isset($headers['content-disposition'])) {
                    continue;
                }

                $filename = null;
                preg_match(
                    '/^(.+); *name="([^"]+)"(; *filename="([^"]+)")?/',
                    $headers['content-disposition'],
                    $matches
                );
                list(, $type, $name) = $matches;

                #process data
                if (isset($matches[4])) { #pull in file
                    $error = UPLOAD_ERR_OK;

                    $filename = $matches[4];
                    $filename_parts = pathinfo($filename);
                    $contentType = 'unknown';

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $contentType = $tmp[0];
                    }

                    $tmpnam = tempnam(ini_get('upload_tmp_dir'), 'php');
                    $fileHandle = fopen($tmpnam, 'wb');


                    if ($fileHandle === false) {
                        $error = UPLOAD_ERR_CANT_WRITE;
                    } else {
                        $lastLine = null;
                        while (($chunk = fgets($stream, $chunkLength)) !== false && strpos($chunk, $boundary) !== 0) {
                            if ($lastLine !== null) {
                                if (fwrite($fileHandle, $lastLine) === false) {
                                    $error = UPLOAD_ERR_CANT_WRITE;
                                    break;
                                }
                            }
                            $lastLine = $chunk;
                        }

                        if ($lastLine !== null && $error !== UPLOAD_ERR_CANT_WRITE) {
                            if (fwrite($fileHandle, rtrim($lastLine, "\r\n")) === false) {
                                $error = UPLOAD_ERR_CANT_WRITE;
                            }
                        }
                    }

                    $_FILES[$name] = [
                        'name' => $filename,
                        'type' => $contentType,
                        'tmp_name' => $tmpnam,
                        'error' => $error,
                        'size' => filesize($tmpnam)
                    ];

                    continue;
                } else { #pull in variable
                    $fullValue = '';
                    $lastLine = null;
                    while (($chunk = fgets($stream)) !== false && strpos($chunk, $boundary) !== 0) {
                        if ($lastLine !== null) {
                            $fullValue .= $lastLine;
                        }

                        $lastLine = $chunk;
                    }

                    if ($lastLine !== null) {
                        $fullValue .= rtrim($lastLine, "\r\n");
                    }

                    if (isset($headers['content-type'])) {
                        $tmp = explode(';', $headers['content-type']);
                        $encoding = '';

                        foreach ($tmp as $t) {
                            if (strpos($t, 'charset') !== false) {
                                $t = explode($t, '=', 2);
                                if (isset($t[1])) {
                                    $encoding = $t[1];
                                }
                                break;
                            }
                        }

                        if ($encoding !== '' && strtoupper($encoding) !== 'UTF-8' && strtoupper($encoding) !== 'UTF8') {
                            $tmp = mb_convert_encoding($fullValue, 'UTF-8', $encoding);
                            if ($tmp !== false) {
                                $fullValue = $tmp;
                            }
                        }

                    }

                    $fullValue = $name . '=' . $fullValue;
                    $origName = $name;
                    $tmp = [];
                    parse_str($fullValue, $tmp);
                    $_POST = $this->recursiveSetter($origName, $_POST, $tmp);
                }
                continue;
            }

            $raw_headers .= $chunk;
        }

        $GLOBALS['_PUT'] = $_POST;
        fclose($stream);
    }
328711
def load_input():
    
    file = open(_input_file, 'r')
    result = json.loads(file.read().strip('\0').strip())
    file.close()
    return result
411027
def simple_input(self, variables):
        
        json_args = fill_template_str(json.dumps(self.data), variables)
        return try_get_objects(json_args)
924130
def json(self, **kwargs):
        '''
        
        '''
        body = self._decompress(self.encoding)
        return _json.loads(body, **kwargs)
632246
def json_requested():
    """"""
    best = request.accept_mimetypes.best_match(
        ['application/json', 'text/html'])
    return (best == 'application/json' and
            request.accept_mimetypes[best] >
            request.accept_mimetypes['text/html'])
1368290
protected function readInput()
    {
        if (!$this->parser) {
            if ('-' !== $this->inputPath) {
                $this->stdin = fopen($this->inputPath, 'r');
            }

            if ('mimedir' === $this->inputFormat) {
                $this->parser = new Parser\MimeDir($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
            } else {
                $this->parser = new Parser\Json($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
            }
        }

        return $this->parser->parse();
    }
61512
@Override
    public Input getInput() {
        return new Input()
                .add("content", String.class, "邮件内容")
                .add("subject", String.class, "邮件标题")
                .add("tos", String.class, "使用逗号分隔的多个邮件地址", REQUIRED);
    }
871890
private function decodeJson($input, $assoc = false)
    {
        $input = trim($input);

        return json_decode($input, $assoc);
    }
36408
public function to_json() {
		parent::to_json();
		foreach ( $this->input_attrs as $attr => $value ) {
			if ( 'style' !== $attr ) {
				$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
				continue;
			}
			$this->json['labelStyle'] = 'style="' . esc_attr( $value ) . '" ';
		}
	}