Serializes the data.

@param array  $data
@param string $group

@return mixed|string
764106
protected function serialize($data, $group = self::SERIALIZE_FULL)
    {
        return $this->get('serializer')->serialize($data, 'json', ['groups' => [$group]]);
    }
431180
protected function getQueuedCallable(array $data)
	{
		if (Str::contains($data['callback'], 'SerializableClosure'))
		{
			if ( class_exists('\SuperClosure\Serializer') )
			{
				return (new \SuperClosure\Serializer)->unserialize($data['callback']);
			}
			else
			{
				return with(unserialize($data['callback']))->getClosure();
			}
		}

		return $data['callback'];
	}
1142678
private function process(array $data) {
    // Group items at first.
    $grouped = [];
    foreach ($data as $locationId => $locationItems) {
      foreach ($locationItems as $item) {
        $grouped[$locationId][$item['class_id']][] = $item;
      }
    }

    $hashes = [];
    $processed = [];

    foreach ($grouped as $locationId => $locationData) {
      foreach ($locationData as $classId => $classData) {
        $hashes[$locationId][$classId] = (string) md5(serialize($classData));

        foreach ($classData as $class) {
          $this->cleanUpTitle($class);
          $class['location_id'] = $locationId;
          $processed[$locationId][$classId][] = $class;
        }
      }
    }

    $this->hashes = $hashes;

    return $processed;
  }
543661
protected function buildResponse(array $data, $serializationGroup = 'Default')
    {
        $response = new Response($this->serialize($data, $serializationGroup));
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
1253136
public function serialize($data) {
        if (is_array($data)) {
            return $this->serializeArray($data);
        } else if (is_object($data)) {
            return $this->serializeItem($data);
        }

        return $data;
    }
401055
public function send(array $data)
    {
        $url = self::SEND_URL.$this->access_token;
        $request = json_encode($data);
        $res = $this->curl->post($url, $request);

        return $res;
    }
1210696
protected function unserialize(string $data)
    {
        $unserializedData = json_decode($data, true);
        $unserializedData['d'] = unserialize($unserializedData['d']);

        return $unserializedData;
    }
78888
public static function deserializeObject(array $data)
    {
        /** @var Bulk $result */
        $result = parent::deserializeObject($data);
        $result->maxOperations = $data['maxOperations'];
        $result->maxPayloadSize = $data['maxPayloadSize'];

        return $result;
    }
619073
public function serialize($data) {
        $list = $this->recursive($data, 1);
        return $this->renderWith(['Result', 'Controller'], ['Data' => \ArrayList::create($list)]);
    }
1151778
public function unserialize($data)
    {
        $serializer = $this->_serializer;

        if ($serializer === 'php') {
            $r = [];
            $offset = 0;
            while ($offset < strlen($data)) {
                if (strpos(substr($data, $offset), '|') === false) {
                    return false;
                }
                $pos = strpos($data, '|', $offset);
                $num = $pos - $offset;
                $key = substr($data, $offset, $num);
                $offset += $num + 1;
                $value = unserialize(substr($data, $offset));
                $r[$key] = $value;
                $offset += strlen(serialize($value));
            }
            return $r;
        } elseif ($serializer === 'php_binary') {
            $r = [];
            $offset = 0;
            while ($offset < strlen($data)) {
                $num = ord($data[$offset]);
                $offset++;
                $key = substr($data, $offset, $num);
                $offset += $num;
                $value = unserialize(substr($data, $offset));
                $r[$key] = $value;
                $offset += strlen(serialize($value));
            }
            return $r;
        } elseif ($serializer === 'php_serialize') {
            return unserialize($data);
        } elseif ($serializer === 'json') {
            return json_decode($data, true);
        } elseif ($serializer === 'igbinary') {
            return igbinary_unserialize($data);
        } elseif ($serializer === 'wddx') {
            return wddx_deserialize($data);
        } else {
            throw new InvalidOptionException(['`:serializer` serializer is not support', 'serializer' => $serializer]);
        }
    }
535982
public static function fromArray(array $data)
    {
        $result = '';
        foreach ($data as $name => $value) {
            $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON);
            $result .= "$name=$value; ";
        }

        return $result === '' ? null : rtrim($result);
    }
1232792
private function renderGroup(array $group)
    {
        if (empty($group)) {
            return '';
        }
        if ($this->groupType === self::GROUP_TYPE_EACH) {
            return implode(PHP_EOL, array_map(function ($namespace) {
                return 'use ' . $namespace . ';';
            }, $group));
        } elseif ($this->groupType === self::GROUP_TYPE_ONE) {
            $group = implode(',' . PHP_EOL . '    ', $group);

            return 'use ' . $group . ';';
        }
    }
1159660
private function convertToJson($data)
    {
        if (is_array($data)) {
            return json_encode($data);
        }

        if ($data instanceof Jsonable) {
            return $data->toJson();
        }

        if ($data instanceof Arrayable) {
            return json_encode($data->toArray());
        }

        return null;
    }
264434
public function filter($data, $group = null)
	{
		// Make sure there is a valid Form XML document.
		if (!($this->xml instanceof \SimpleXMLElement))
		{
			return false;
		}

		$input = new Registry($data);
		$output = new Registry;

		// Get the fields for which to filter the data.
		$fields = $this->findFieldsByGroup($group);

		if (!$fields)
		{
			// PANIC!
			return false;
		}

		// Filter the fields.
		foreach ($fields as $field)
		{
			$name = (string) $field['name'];

			// Get the field groups for the element.
			$attrs = $field->xpath('ancestor::fields[@name]/@name');
			$groups = array_map('strval', $attrs ? $attrs : array());
			$group = implode('.', $groups);

			// Get the field value from the data input.
			if ($group)
			{
				// Filter the value if it exists.
				if ($input->exists($group . '.' . $name))
				{
					$output->set($group . '.' . $name, $this->filterField($field, $input->get($group . '.' . $name, (string) $field['default'])));
				}
			}
			else
			{
				// Filter the value if it exists.
				if ($input->exists($name))
				{
					$output->set($name, $this->filterField($field, $input->get($name, (string) $field['default'])));
				}
			}
		}

		return $output->toArray();
	}
613870
protected function encode(array $data)
    {

        foreach ($data as $key => $value) {
            if (is_string($value)) {
                $data[$key] = base64_encode($value);
            }
        }

        return $data;
    }
1073125
public function encode(array $data): string
    {
        $options = JSON_PRESERVE_ZERO_FRACTION | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES;
        if ($this->prettyPrint) {
            $options = $options | JSON_PRETTY_PRINT;
        }

        return json_encode($data, $options);
    }
849414
public function deserialize(array $data)
    {
        $original = $data;
        $this->deserializeTos($data);
        $data = $this->getJavascriptsData($data);
        $data = $this->getLogoData($data);
        unset($data['tos']['text']);
        //maybe move this somewhere else
        unset($data['archives']);

        $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data);
        ksort($data);
        $data = json_encode($data, JSON_PRETTY_PRINT);

        file_put_contents($this->filePath, $data);

        return $original;
    }