Evaulate Json.

@param $value Value to be checked

@return bool
482889
public function validate($value)
    {
        if ($this->notBeEmpty($value)) {
            $value = json_decode($value);
            if ($value !== null) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
735950
public function encodeJson($value)
    {
        if ($value instanceof Arrayable) {
            return $this->encodeArrayable($value);
        } else if (is_array($value)) {
            return $this->encodeArray($value);
        } else if (is_object($value)) {
            return $this->encodeArray((array) $value);
        } else {
            return $value;
        }
    }
221781
protected function prepareValue($value)
    {
        if ($this->hasMutator()) {
            return call_user_func($this->getMutator(), $value);
        } elseif ($value && $this->isElementOfDate() && $this->isDateCastable()) {
            $value = $this->castValueAsDateTime($value);
            if ($this instanceof Timestamp) {
                $value = $value->getTimestamp();
            }

            return $value;
        }

        if (! is_null($value)) {
            if ($this->isJsonCastable()) {
                return $this->castValueAsJson($value);
            } elseif ($this->isCommaCastable()) {
                return $this->castValueAsCommaSeparated($value);
            }
        }

        return $value;
    }
205326
protected function parseValue($value) {
        switch ($this->array_literals_behavior) {
            case self::PARSE_JSON:
                if (in_array(substr($value, 0, 1), array('[', '{')) && in_array(substr($value, -1), array(']', '}'))) {
                    if (defined('JSON_BIGINT_AS_STRING')) {
                        $output = json_decode($value, true, 512, JSON_BIGINT_AS_STRING);
                    } else {
                        $output = json_decode($value, true);
                    }

                    if ($output !== NULL) {
                        return $output;
                    }
                }
            // fallthrough
            // try regex parser for simple estructures not JSON-compatible (ex: colors = [blue, green, red])
            case self::PARSE_SIMPLE:
                // if the value looks like [a,b,c,...], interpret as array
                if (preg_match('/^\[\s*.*?(?:\s*,\s*.*?)*\s*\]$/', trim($value))) {
                    return array_map('trim', explode(',', trim(trim($value), '[]')));
                }
                break;
        }
        return $value;
    }
951022
public function setJsonValue(array $value)
    {
        $value = array_map(
            function ($value) {
                return str_replace(':', '', $value);
            },
            $value
        );
        parent::setJsonValue($value);
    }
1159646
public function marshal($value)
    {
        if (is_array($value) || $value === null) {
            return $value;
        }

        return json_decode($value, true);
    }
367374
public static function isJson($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        if (((string) $value) === 'null') {
            return true;
        }

        return (json_decode((string) $value) !== null && json_last_error() === JSON_ERROR_NONE);
    }
907027
public function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }

        // From json-schema definition: if "items" is not present, or its value is an object,
        // validation of the instance always succeeds, regardless of the value of "additionalItems";
        if (empty($this->items)) {
            return true;
        }

        return $this->executeItemsValidation($value);
    }
957480
protected function valueToJsonLd($value)
    {
        if (is_array($value)) {
            $return = [];
            foreach ($value as $item) {
                $return[] = $this->valueToJsonLd($item);
            }

            return $return;
        } elseif ($value instanceof Type\EnumerationType || $value instanceof Type\Enumeration) {
            return $value->getSchemaUrl();
        } elseif ($value instanceof Type\TypeInterface) {
            return $this->typeToJsonLd($value);
        } elseif ($value instanceof Property\PropertyInterface) {
            return $this->propertyToJsonLd($value);
        } elseif ($value instanceof DataType\DataTypeInterface) {
            return $this->dataTypeToJsonLd($value);
        }

        throw new \Exception('Unexpected data type '.gettype($value));
    }
373918
public function jsonEncode($value)
    {
        // if json_encode exists use that
        if (extension_loaded('json') && function_exists('json_encode')) {
            $encodedValue = json_encode($value);
            if (!empty($encodedValue)) {
                return $encodedValue;
            }
        }

        try {
            return \Zend\Json\Encoder::encode($value);
        } catch (Exception $exception) {
            return false;
        }
    }
264555
public function isTemporary(string $value): bool
    {
        try {
            $response = $this->client->request('GET', sprintf('%s/detect/%s', self::API_URL, $value));
        } catch (GuzzleException $exception) {
            throw Exception::fromMessage($exception->getMessage());
        }

        $decoded = json_decode($response->getBody()->getContents(), true);

        return (bool)($decoded['temporary'] ?? false);
    }
345162
protected function serializeValue($value)
    {
        $serialized = var_export($value, true);
        if ($serialized === 'NULL') {
            $serialized = strtolower($serialized);
        }

        return $serialized;
    }
484806
protected function resolveValue($value)
    {
        do {
            if ($value instanceof \JsonSerializable) {
                $value = $value->jsonSerialize();
            } elseif ($value instanceof \Closure) {
                $value = $value();
            } else {
                break;
            }
        } while (true);

        return $value;
    }
1004056
protected function getJsonValue($value, $event)
    {
        switch ($event) {
            case ActiveRecord::EVENT_BEFORE_INSERT:
            case ActiveRecord::EVENT_BEFORE_UPDATE:
                if (is_array($value)) {
                    $value = json_encode($value);
                }
                break;
            case ActiveRecord::EVENT_AFTER_FIND:
                $value = @json_encode($value, true) ?: $value;
                break;
        }
        return $value;
    }
428549
public function beforeSaveValue($value)
    {
        try
        {
            $value      = Json::encode($value);
        } catch (\Exception $e)
        {
            $value      = "{}";
        }

        return $value;
    }
714736
protected static function getArrayIfJSON($value)
    {
        if (is_array($value)) {
            return $value;
        } else {
            $toArray = json_decode($value, true);

            if (json_last_error() === JSON_ERROR_NONE) {
                return $toArray;
            } else {
                return $value;
            }
        }
    }
681628
private function serializeValue($value)
    {
        if (is_object($value)) {
            return $this->serializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->serializeArrayRecursively($value);
        }

        return $value;
    }