if content is an array, then convert to json
@param mixed $content
502442
public function setDataContent($content)
    {
        if (is_array($content)) {
            $this->headers->set('Content-Type', 'application/json');
            $content = json_encode($content);
        }

        $this->setContent($content);
    }
611189
public function setContent($content) : Response
    {
        if (is_resource($content)) {
            $body = new MessageBodyResource($content);
        } else {
            $body = new MessageBodyString($content);
        }

        return $this->setBody($body);
    }
1017343
private function prepareContent($content)
    {
        $this->content = $content;

        if (!($this->content instanceof StreamInterface)) {
            $this->content = Stream::factory($this->content);
        } elseif ($this->content instanceof MultipartBody) {
            if (!$this->hasHeader('Content-Disposition')) {
                $disposition = 'form-data; name="' . $this->name .'"';
                $this->headers['Content-Disposition'] = $disposition;
            }

            if (!$this->hasHeader('Content-Type')) {
                $this->headers['Content-Type'] = sprintf(
                    "multipart/form-data; boundary=%s",
                    $this->content->getBoundary()
                );
            }
        }
    }
658516
protected function ajaxContent($content)
    {
        $message = null;

        $this->header('Content-Type', 'application/json');

        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        } elseif (is_string($content)) {
            $content = ['content' => $content];
        } elseif (!is_array($content) && !$content instanceof \Exception) {
            return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST));
        } elseif ($content instanceof \Exception) {

            $this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode());

            $message = $content->getMessage();

            if ($content instanceof MbException) {
                $content = $content->getMessages();
            } else {
                $content = null;
            }
        }

        $this->original = [
            'meta' => [
                'code'    => $this->getStatusCode(),
                'message' => $message,
            ],
            'data' => $content,
        ];

        $this->getMbAudit()->setResponseType('ajax');
        $this->getMbAudit()->setResponseData($this->original);

        return $this->original;
    }
42727
public function setContent($content)
    {
        $this->content = null;
        if ($content === null) {
            return;
        }

        if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) {
            $this->content = (string)$content;
        }

        if (is_resource($content)) {
            $this->content = $content;
        }

        return $this;
    }
171960
protected function _defaultData($content)
    {
        $content = @unserialize($content);
        return (empty($content) || !is_array($content)) ? [] : $content;
    }
393229
protected function parseMessageFromRequest($content)
    {
        $content = strval($content);

        $arrayable = json_decode($content, true);
        if (json_last_error() === JSON_ERROR_NONE) {
            return $arrayable;
        }

        if (!$this->encryptor) {
            throw new RuntimeException('Safe mode Encryptor is necessary, please use Guard::setEncryptor(Encryptor $encryptor) set the encryptor instance.');
        }

        $message = $this->encryptor->decryptMsg(
            $this->request->get('msg_signature'),
            $this->request->get('nonce'),
            $this->request->get('timestamp'),
            $content
        );

        return $message;
    }
1321867
public function setJsonContent($content)
    {
        $context = $this->_context;

        $this->setHeader('Content-Type', 'application/json; charset=utf-8');

        if (is_array($content)) {
            if (!isset($content['code'])) {
                $content = ['code' => 0, 'message' => '', 'data' => $content];
            }
        } elseif ($content instanceof \JsonSerializable) {
            $content = ['code' => 0, 'message' => '', 'data' => $content];
        } elseif (is_string($content)) {
            null;
        } elseif (is_int($content)) {
            $content = ['code' => $content, 'message' => ''];
        } elseif ($content === null) {
            $content = ['code' => 0, 'message' => '', 'data' => null];
        } elseif ($content instanceof ValidatorException) {
            $content = ['code' => -2, 'message' => $content->getMessage()];
        } elseif ($content instanceof \Exception) {
            if ($content instanceof \ManaPHP\Exception) {
                $this->setStatus($content->getStatusCode());
                $content = $content->getJson();
            } else {
                $this->setStatus(500);
                $content = ['code' => 500, 'message' => 'Server Internal Error'];
            }
        }

        $context->content = $this->_jsonEncode($content);

        return $this;
    }
1280738
public function removeContent( ...$content ) {
		if ( is_array( $content[ 0 ] ) ) {
			$content = $content[ 0 ];
		}
		foreach ( $content as $item ) {
			if ( !is_string( $item ) ) {
				// Use strict type comparions so we don't
				// compare objects with existing strings
				$index = array_search( $item, $this->content, true );
				if ( $index !== false ) {
					array_splice( $this->content, $index, 1 );
				}
			}
		}
		return $this;
	}
1323157
public function json($content)
    {
        $this->header('Content-Type', 'application/json');
        $this->json = true;
        $this->content = $content;

        return $this;
    }
519006
private function getContentData($content)
    {
        $res = [];
        $res['startStringPos'] = strpos($content, $this->startString) + strlen($this->startString);
        $res['endStringPos'] = strpos($content, $this->endString);
        $res['bundleList'] = substr($content, $res['startStringPos'], ($res['endStringPos'] - $res['startStringPos']));
        return $res;
    }
549426
protected function parseContent($content) {
		$lines  = explode(PHP_EOL, $content);
		$result = [];
		
		foreach ($lines as $lineNm => $lineRaw) {
			if (empty($lineRaw)) {
				continue;
			}
			
			$line = str_getcsv($lineRaw, $this->csvDelimiter, $this->csvEnclosure);
			
			// Lack of data detection
			if (count($line) < 2) {
				$template = 'Error has occurred while parsing CSV file for the file: "%s" on line %s';
				throw new ParseError(sprintf($template, $this->lastFilePath, $lineNm));
			}
			
			$id = trim($line[0]);
			
			// Override detection
			if (isset($result[$id])) {
				$template = 'Translation with ID "%s" is already defined in the file "%s"';
				throw new ParseError(sprintf($template, $id, $this->lastFilePath));
			}
			
			$result[$id] = trim($line[1]);
		}
		
		return $result;
	}
1070833
protected function _getContent($content)
    {
        if(!isset($content))
            return;

        if(is_array($content))
            return array_map(
                function ($value) {
                    return $this->_getContent($value);
                }, $content
            );

        switch(gettype($content)) {
            case 'string': case 'integer': case 'double': case 'float':
                return $content;
            break;
            case 'object':
                if('Closure' == get_class($content)) {
                    ob_start();
                    ob_clean();
                    $returned = $content($this->data);
                    $output = ob_get_clean();
                    if(isset($returned))
                        return $returned;
                    else
                        return $output;
                } elseif(isset($content->content))
                    return $content->content;
            break;
            default:
                throw new \InvalidArgumentException('wrong view content type : '.gettype($content));
        }
    }
859638
protected function parseJson($content)
    {
        $content = json_decode($content, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \UnexpectedValueException(sprintf(
                "JSON 解析失败: %s",
                json_last_error_msg()
            ));
        }

        return $content;
    }
789775
public function setContent($content)
	{
		$this->original = $content;

		$status = $this->getStatusCode();
		$reason = '';
		$output = '';

		switch ($this->headers->get('content-type'))
		{
			case 'text/plain':
				/*if ($suppress_response_codes)
				{
					$output .= "Status: $status\n";
					$output .= "Reason: $reason\n";
					$output .= "\n";
				}*/

				if (!is_object($content) && !is_array($content))
				{
					$output .= $content;
				}
				else
				{
					$output .= json_encode($content);
				}
			break;

			case 'text/html':
				$reason  = htmlspecialchars($reason);
				$content = htmlspecialchars($content);

				$output .= "<!DOCTYPE html>\n";
				$output .= "<html lang='en'>\n";
				$output .= "<head>\n";
				$output .= "<meta charset='utf-8'>\n";
				$output .= "<title>$status $reason</title>\n";
				$output .= "</head>\n";
				$output .= "<body>\n";
				$output .= '<div class="error">' . "\n";

				$output .= '<h1 id="reason">' . $reason . "</h1>\n";

				if ($suppress_response_codes)
				{
					$output .= '<p id="status">' . htmlspecialchars($status) . "</p>\n";
				}

				if (!is_object($content) && !is_array($content))
				{
					$output .= '<p id ="message">' . $content . "</p>\n";
				}
				else
				{
					$output .= '<p id ="message">' . json_encode($content) . "</p>\n";
				}

				$output .= "</div>\n";
				$output .= "</body>\n";
				$output .= "</html>";
			break;
			case 'application/xhtml+xml':
				$reason  = htmlspecialchars($reason);
				$content = htmlspecialchars($content);

				$output .= '<?xml version="1.0" ?>' . "\n";
				$output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
				$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">' . "\n";
				$output .= "<head>\n";
				$output .= "<title>$status $reason</title>\n";
				$output .= "</head>\n";
				$output .= "<body>\n";
				$output .= '<div class="error">' . "\n";

				$output .= '<h1 id="reason">' . $reason . "</h1>\n";

				if ($suppress_response_codes)
				{
					$output .= '<p id="status">' . htmlspecialchars($status) . "</p>\n";
				}
				if (!is_object($content) && !is_array($content))
				{
					$output .= '<p id ="message">' . $content . "</p>\n";
				}
				else
				{
					$output .= '<p id ="message">' . json_encode($content) . "</p>\n";
				}

				$output .= "</div>\n";
				$output .= "</body>\n";
				$output .= "</html>";
			break;
			case "application/xml":
				$output .= Xml::encode($content);
			break;
			case 'application/json':
				$output .= json_encode($content);
			break;
			case 'application/javascript':
				$output .= $content;
			break;
			case 'application/vnd.php.serialized':
				$output .= serialize($content);
			break;
			case 'application/php':
				$output .= var_export($content, true);
			break;
			case 'application/x-www-form-urlencoded':
				if (!is_object($content))
				{
					$output .= $content;
				}
				else
				{
					$output .= json_encode($content);
				}
			break;
		}

		return parent::setContent($output);
	}
1156807
public function parseLang($content) {
        $this->_content = $content;
        $this->_parseDebugStart();
        $this->_parsePath();
        $this->_parseGravatar();
        $this->_parseUrl();
        $this->_parsePhp();
        $this->_parseLang();
        $this->_parseForeach();
        $this->_parseFor();
        $this->_parseVar();
        $this->_parseVarFunc();
        $this->_parseCondition();
        $this->_parseFunction();
        $this->_parseException();
        $this->_parseDebugEnd();

        return $this->_content;
    }
1343176
private function recursivelyArrayify($content = null)
        {
            $return = [];
            if (false === $content || null === $content) {
                return;
            } else if ($content instanceof Element) {
                $return[] = $content->toArray();
            } else if (!is_array($content)) {
                $return[] = $content;
            } else {
                foreach ($content as $element) {
                    $return[] = $this->recursivelyArrayify($element);
                }
            }
            return $return;
        }