import raw JSON data for process

@param string $data
@return jsonq
506388
public function json($data)
    {
        $json = $this->isJson($data, true);

        if ($json) {
            return $this->collect($json);
        }

        return $this;
    }
378888
public function json( $data ) {
		$response = $this->response();
		$response = $response->withHeader( 'Content-Type', 'application/json' );
		$response = $response->withBody( Psr7\stream_for( wp_json_encode( $data ) ) );
		return $response;
	}
1198982
public static function loadSerializedJsonJWE(array $data)
    {
        $jwe = new JWE();
        $jwe = $jwe->withCiphertext(Base64Url::decode($data['ciphertext']));

        self::populateIV($jwe, $data);
        self::populateAAD($jwe, $data);
        self::populateTag($jwe, $data);
        self::populateSharedProtectedHeaders($jwe, $data);
        self::populateSharedHeaders($jwe, $data);

        foreach ($data['recipients'] as $recipient) {
            $encrypted_key = self::getRecipientEncryptedKey($recipient);
            $recipient_headers = self::getRecipientHeaders($recipient);

            $jwe = $jwe->addRecipientWithEncryptedKey($encrypted_key, $recipient_headers);
        }

        return $jwe;
    }
553950
public static function createFromDecodedJsonResponse($data)
    {
        // Make sure to build the SubjectArea with correct defaults in case of missing attributes.
        $data = array_merge(['x' => 0, 'y' => 0, 'width' => 1, 'height' => 1], $data);

        return new self(
            max(0, $data['x']),
            max(0, $data['y']),
            max(1, $data['width']),
            max(1, $data['height'])
        );
    }
126243
function import($data)
    {
        if ($data === null)
            return $this;

        if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass))
            throw new \InvalidArgumentException(sprintf(
                'Data must be instance of \Traversable, \stdClass or array. given: (%s)'
                , \Poirot\Std\flatten($data)
            ));

        if ($data instanceof \stdClass)
            $data = \Poirot\Std\toArrayObject($data);

        
        foreach ($data as $k => $v)
            $this->set($k, $v);

        return $this;
    }
252271
protected static function pretty_json($data)
	{
		$json = json_encode($data, \Config::get('format.json.encode.options', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP));

		if ( ! $json)
		{
			return false;
		}

		$tab = "\t";
		$newline = "\n";
		$new_json = "";
		$indent_level = 0;
		$in_string = false;
		$len = strlen($json);

		for ($c = 0; $c < $len; $c++)
		{
			$char = $json[$c];
			switch($char)
			{
				case '{':
				case '[':
					if ( ! $in_string)
					{
						$new_json .= $char.$newline.str_repeat($tab, $indent_level+1);
						$indent_level++;
					}
					else
					{
						$new_json .= $char;
					}
					break;
				case '}':
				case ']':
					if ( ! $in_string)
					{
						$indent_level--;
						$new_json .= $newline.str_repeat($tab, $indent_level).$char;
					}
					else
					{
						$new_json .= $char;
					}
					break;
				case ',':
					if ( ! $in_string)
					{
						$new_json .= ','.$newline.str_repeat($tab, $indent_level);
					}
					else
					{
						$new_json .= $char;
					}
					break;
				case ':':
					if ( ! $in_string)
					{
						$new_json .= ': ';
					}
					else
					{
						$new_json .= $char;
					}
					break;
				case '"':
					if ($c > 0 and $json[$c-1] !== '\\')
					{
						$in_string = ! $in_string;
					}
				default:
					$new_json .= $char;
					break;
			}
		}

		return $new_json;
	}
1315386
public function getDataForJSON($data = null)
    {
        if (is_null($data)) {
            $data = $this->getData();
        }
        $dataForJSON = parent::getDataForJSON($data);
        if (!is_null($this->atomic)) {
            $dataForJSON['@atomic'] = $this->atomic;
        }
        if (isset($this->sourceId)) {
            $dataForJSON['@sourceId'] = $this->sourceId;
            $this->sourceId = null;
        }
        return $dataForJSON;
    }
790464
protected function serialize($data)
    {
        if ('' === trim($data)) {
            return null;
        }

        if (null === $result = json_decode($data, true)) {
            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new ReadException(json_last_error_msg(), json_last_error());
            }
        }

        return new ParameterBag($result);
    }
235574
public function import(&$data) {
        $attributes = $this->getAttributes();
        $values = $this->getValues($data);

        $countInserts = 0;
        $chunks = array_chunk($values, $this->maxItemsPerInsert);
        foreach ($chunks as $chunk) {//Execute multiple queries
            $countInserts += \Yii::$app->db->createCommand()
                            ->batchInsert($this->tableName, $attributes, $chunk)->execute();
        }
        return $countInserts;
    }
452035
protected function processData($data)
    {
        if (is_object($data)) {
            if ($data instanceof ObjectID ||
                $data instanceof Regex ||
                $data instanceof UTCDateTime ||
                $data instanceof Timestamp
            ) {
                $data = get_class($data) . '(' . $data->__toString() . ')';
            } elseif ($data instanceof Javascript) {
                $data = $this->processJavascript($data);
            } elseif ($data instanceof MinKey || $data instanceof MaxKey) {
                $data = get_class($data);
            } elseif ($data instanceof Binary) {
                if (in_array($data->getType(), [Binary::TYPE_MD5, Binary::TYPE_UUID, Binary::TYPE_OLD_UUID], true)) {
                    $data = $data->getData();
                } else {
                    $data = get_class($data) . '(...)';
                }
            } elseif ($data instanceof Type) {
                // Covers 'Binary', 'DBRef' and others
                $data = get_class($data) . '(...)';
            } else {
                $result = [];
                foreach ($data as $name => $value) {
                    $result[$name] = $value;
                }
                $data = $result;
            }

            if ($data === []) {
                return new \stdClass();
            }
        }

        if (is_array($data)) {
            foreach ($data as $key => $value) {
                if (is_array($value) || is_object($value)) {
                    $data[$key] = $this->processData($value);
                }
            }
        }

        return $data;
    }
685776
public function serialize($data)
    {
        $json = '';
        $formattedData = null;

        if ($data instanceof DataObject) {
            $formattedData = $this->formatDataObject($data);
        } elseif ($data instanceof DataList) {
            $formattedData = $this->formatDataList($data);
        }

        if ($formattedData !== null) {
            $json = $this->jsonify($formattedData);
        } else {
            //fallback: convert non array to object then encode
            if (!is_array($data)) {
                $data = (object) $data;
            }
            $json = $this->jsonify($data);
        }

        return $json;
    }
1210868
public function importJson($jsonData)
    {
        $json = json_decode($jsonData, true);

        if ($json === null) {
            throw new \InvalidArgumentException("Footprint json is not a valid");
        }

        if (!is_array($json)) {
            throw new \InvalidArgumentException("Footprint json data is not a valid");
        }

        $this->_data += $json;
    }
768184
protected static function dataToString($data)
    {
        if (!is_string($data))
        {
            try
            {
                $data = \GuzzleHttp\json_encode($data);
            }
            catch (\InvalidArgumentException $e)
            {

            }
        }

        return $data;
    }
553740
public function serialize($data)
    {
        if (is_string($data) === true) {
            return $data;
        } else {
            $data = json_encode($data);
            if ($data === '[]') {
                return '{}';
            } else {
                return $data;
            }
        }


    }
843369
public function importDataV1x(array $data)
    {
        $this->_packageXml = null;
        $this->_init();
        // Import simple data
        if (isset($data['name'])) {
            $this->setName($data['name']);
        }
        if (isset($data['summary'])) {
            $this->setSummary($data['summary']);
        }
        if (isset($data['description'])) {
            $this->setDescription($data['description']);
        }
        if (isset($data['channel'])) {
            $this->setChannel($this->convertChannelFromV1x($data['channel']));
        }
        if (isset($data['license'])) {
            if (is_array($data['license'])) {
                $this->setLicense($data['license']['_content'], $data['license']['attribs']['uri']);
            } else {
                $this->setLicense($data['license']);
            }
        }
        if (isset($data['version'])) {
            $this->setVersion($data['version']['release']);
        }
        if (isset($data['stability'])) {
            $this->setStability($data['stability']['release']);
        }
        if (isset($data['notes'])) {
            $this->setNotes($data['notes']);
        }
        if (isset($data['date'])) {
            $this->setDate($data['date']);
        }
        if (isset($data['time'])) {
            $this->setTime($data['time']);
        }

        // Import authors
        $authors = array();
        $authorRoles = array('lead', 'developer', 'contributor', 'helper');
        foreach ($authorRoles as $authorRole) {
            if (isset($data[$authorRole])) {
                $authorList = $data[$authorRole];
                if (!is_array($authorList) || isset($authorList['name'])) {
                    $authorList = array($authorList);
                }
                foreach ($authorList as $authorRawData) {
                    $author = array();
                    $author['name'] = $authorRawData['name'];
                    $author['user'] = $authorRawData['user'];
                    $author['email'] = $authorRawData['email'];
                    array_push($authors, $author);
                }
            }
        }
        $this->setAuthors($authors);

        // Import dependencies
        $packages = array();
        $extensions = array();
        if (isset($data['dependencies']) && is_array($data['dependencies'])) {
            $dependencySections = array('required', 'optional');
            $elementTypes = array('package', 'extension');
            foreach ($dependencySections as $dependencySection) {
                if (isset($data['dependencies'][$dependencySection])) {
                    // Handle required PHP version
                    if ($dependencySection == 'required' && isset($data['dependencies']['required']['php'])) {
                        $this->setDependencyPhpVersion($data['dependencies']['required']['php']['min'], $data['dependencies']['required']['php']['max']);
                    }
                    // Handle extensions
                    if (isset($data['dependencies'][$dependencySection]['extension'])) {
                        $extensionList = $data['dependencies'][$dependencySection]['extension'];
                        if (!is_array($extensionList) || isset($extensionList['name'])) {
                            $extensionList = array($extensionList);
                        }
                        foreach ($extensionList as $extensionRawData) {
                            $extension = array();
                            $extension['name'] = $extensionRawData['name'];
                            $extension['min_version'] = isset($extensionRawData['min']) ? $extensionRawData['min'] : null;
                            $extension['max_version'] = isset($extensionRawData['max']) ? $extensionRawData['max'] : null;
                            array_push($extensions, $extension);
                        }
                    }
                    // Handle packages
                    if (isset($data['dependencies'][$dependencySection]['package'])) {
                        $packageList = $data['dependencies'][$dependencySection]['package'];
                        if (!is_array($packageList) || isset($packageList['name'])) {
                            $packageList = array($packageList);
                        }
                        foreach ($packageList as $packageRawData) {
                            $package = array();
                            $package['name'] = $packageRawData['name'];
                            $package['channel'] = $this->convertChannelFromV1x($packageRawData['channel']);
                            $package['min_version'] = isset($packageRawData['min']) ? $packageRawData['min'] : null;
                            $package['max_version'] = isset($packageRawData['max']) ? $packageRawData['max'] : null;
                            array_push($packages, $package);
                        }
                    }
                }
            }
        }
        $this->setDependencyPackages($packages);
        $this->setDependencyPhpExtensions($extensions);

        // Import contents
        if (isset($data['contents']) && is_array($data['contents']) && is_array($data['contents']['dir'])) {
            // Handle files
            $root = $data['contents']['dir'];
            if (isset($data['contents']['dir']['file'])) {
                $fileList = $data['contents']['dir']['file'];
                if (!is_array($fileList) || isset($fileList['attribs'])) {
                    $fileList = array($fileList);
                }
                foreach ($fileList as $fileRawData) {
                    $targetName = $fileRawData['attribs']['role'];
                    $parentTargetNode = $this->_getNode('target', $this->_packageXml->contents, $targetName);
                    $filePath = $fileRawData['attribs']['name'];
                    $filePathParts = explode('/', $filePath);
                    $fileName = array_pop($filePathParts);
                    $parentDirNode = null;
                    if (!empty($filePathParts)) {
                        $parentDirNode = $parentTargetNode;
                        foreach ($filePathParts as $directoryName) {
                            $parentDirNode = $this->_getNode('dir', $parentDirNode, $directoryName);
                        }
                    } else {
                        $parentDirNode = $this->_getNode('dir', $parentTargetNode, '.');
                    }
                    $fileNode = $parentDirNode->addChild('file');
                    $fileNode->addAttribute('name', $fileName);
                    $fileNode->addAttribute('hash', $fileRawData['attribs']['md5sum']);
                }
            }
        }

        return $this;
    }
437437
function import ($data)
  {
    if ($data instanceof AssignableInterface)
      $data = $data->export ();
    foreach ($data as $k => $v)
      $this->$k = $v;
    return $this;
  }
509776
final function import($data)
    {
        if ($data === null)
            return $this;

        if (!(is_array($data) || $data instanceof \Traversable || $data instanceof \stdClass))
            throw new \InvalidArgumentException(sprintf(
                'Data must be instance of \Traversable, \stdClass or array. given: (%s) on (%s).'
                , \Poirot\Std\flatten($data), get_class($this)
            ));

        if ($data instanceof \stdClass)
            $data = \Poirot\Std\toArrayObject($data);

        $this->doSetFrom($data);

        return $this;
    }