return json Response
@param bool $asArray return as Array?
@return \stdClass|array
17866
public function getJson($asArray = false)
    {
        if ($this->isJson())
            return json_decode($this->getBody(), $asArray);
        return null;
    }
506937
public function toArray($asArrayObject = false)
    {
        $data = [];
        foreach ($this->data as $k => $v) {
            $data[$k] = $this->isInstanceOf($v, $this) ? $v->toArray() : $v;
        }

        return $asArrayObject ? $this->arr($data) : $data;
    }
478120
public function jsonSerialize(): array
    {
        $returnArray = [];
        foreach ($this->getArrayCopy() as $value) {
            $returnArray[] = $value->JsonSerialize();
        }
        return $returnArray;
    }
736994
public function getCategoryValues($asArray = null)
    {
        if (!$this->owner->getIsNewRecord() && $this->_categoryValues === null) {
            $this->_categoryValues = [];

            /* @var ActiveRecord $category */
            foreach ($this->owner->{$this->categoryRelation} as $category) {
                $this->_categoryValues[] = $category->getAttribute($this->categoryValueAttribute);
            }
        }

        if ($asArray === null) {
            $asArray = $this->categoryValuesAsArray;
        }

        if ($asArray) {
            return $this->_categoryValues === null ? [] : $this->_categoryValues;
        } else {
            return $this->_categoryValues === null ? '' : implode(', ', $this->_categoryValues);
        }
    }
783261
public function toArray($asAlias = false, $returnHidden = true) {

        $method = $asAlias ? "getAlias" : "getProperty";

        $dados = [];

        foreach (self::$schema->getProperties() as $item) {

            if (!$returnHidden && $item->getBehavior()->isHidden()) {
                continue;
            }

            if (method_exists($this, "get" . $item->getProperty())) {
                $value = $this->{"get" . $item->getProperty()}();
            } else {
                $value = $this->{$item->getProperty()};
            }

            if (is_null($value)) {
                continue;
            }

            if(is_array($value)){
                $dados[$item->{$method}()] = [];

                foreach ($value as $valueItem) {
                    $valueItem = is_object($valueItem) ? $valueItem->toArray($asAlias, $returnHidden) : $valueItem;

                    $dados[$item->{$method}()][] = $valueItem;
                }

                continue;
            }

            switch ($item->getType()) {
                case 'json':
                    $decoded = json_decode($value, true);

                    $dados[$item->{$method}()] = !empty($decoded) ? $decoded : $value;
                    break;
                default:
                    $value = is_object($value) ? $value->toArray($asAlias, $returnHidden) : $value;

                    $dados[$item->{$method}()] = $value;
                    break;
            }
        }

        return $dados;
    }
146423
public static function jsonToArray($json = false) {

        if ($json && Validate::isJson($json)) {

            $object = json_decode($json);
            return self::objectToArray($object);
        }

        return false;
    }
968098
public function getResponse()
    {
        $obj = new \stdClass();
        $obj->ret = $this->ret;
        $obj->msg = $this->msg;
        $obj->data = $this->data;

        return json_encode($obj);
    }
720570
public function getMimeType($asArray = false)
    {
        $asArray   = (bool) $asArray;
        $mimetype = (string) $this->_mimetype;
        if ($asArray) {
            $mimetype = explode(',', $mimetype);
        }

        return $mimetype;
    }
412488
public function read($length = 0, $asArray = false)
    {
        if ($asArray &&
            Number::isZero($length)) {

            return file($this->file);
        } elseif (Number::isPositive($length)) {
            $this->setHandle('r');

            return fread($this->handle, $length);
        } else {
            return Collection::implode($this->read(0, true), '');
        }
    }
141714
protected function responseJson($data, $status = null, $encodingOptions = 0)
    {
        $body = $this->_response->getBody();
        $body->rewind();
        $body->write($json = json_encode($data, $encodingOptions));
        // Ensure that the json encoding passed successfully
        if ($json === false) {
            throw new \RuntimeException(json_last_error_msg(), json_last_error());
        }
        $responseWithJson = $this->_response->withHeader('Content-Type', 'application/json;charset=utf-8');
        if (isset($status)) {
            return $responseWithJson->withStatus($status);
        }
        return $responseWithJson;
    }
864311
protected function _userData($asArray = true) {
		if ($asArray === true) {
			if (is_a($this->_userData, '\Cake\ORM\Entity')) {
				$this->_userData = $this->_userData->toArray();
			}
		}

		return $this->_userData;
	}
488150
public function getArray($asAssoc = true)
    {
        // get all attribute names
        $attributes = $this->keys();
        $values = [];

        if (!empty($attributes)) {
            foreach ($attributes as $attribute) {
                $value = $this->get($attribute, false);

                if ($asAssoc === true) {
                    $values[$attribute] = $value;
                } else {
                    $values[] = $value;
                }
            }
        }

        return $values;
    }
1374391
public function response($data = [], $status = Response::HTTP_OK, $headers = [])
    {
        return new JsonResponse($data, $status, $headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    }
186328
public static function fromJson($json)
    {
        $responseData = json_decode($json, true);

        if (! $responseData) {
            return new Response(false, ['invalid-json']);
        }

        if (isset($responseData['success']) && $responseData['success'] == true) {
            return new Response(true);
        }

        if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
            return new Response(false, $responseData['error-codes']);
        }

        return new Response(false);
    }
381528
public static function getResultsFromJson($jsonEncodedResponse)
    {
        $responseData = json_decode($jsonEncodedResponse, true);

        if (is_array($responseData['actionResults'])) {
            foreach ($responseData['actionResults'] as $action => $serializedActionResult) {
                $responseData['actionResults'][$action] = unserialize($serializedActionResult);
            }
        } elseif (is_null($responseData)) {
            $responseData = false;
        }

        return $responseData;
    }
883760
protected function jsonResponse($data = null, array $headers = array(), array $httpHeaders = array())
    {
        $headers = array_replace_recursive(array(
            'status' => array(
                'code'    => 200,
                'message' => 'OK',
            ),
            'version' => 'v1',
        ), $headers);

        $data = array(
            'headers'  => $headers,
            'response' => $data,
        );

        // Debug data
        if (Config::get('app.debug', false) && Input::get('debug', false) == true) {
            $data['debug'] = $this->debugDatas();
        }

        $response = Response::make(json_encode($data), $headers['status']['code']);

        // HTTP headers
        foreach ($httpHeaders as $k => $v) {
            $response->header($k, $v);
        }
        $response
            ->header('Content-Type', 'application/json')
            ->setEtag(md5(json_encode($data)))
        ;

        return $response;
    }
369128
public function getFiles($asArray = false)
    {
        $return = array();
        if ($asArray && $this->files) {
            foreach ($this->files as $file) {
                $return[] = $file->toArray();
            }
        }

        return $asArray ? $return : $this->files;
    }