Filter a value to be a Json

@param  string                              $value
@param  null                                $annotation Unused
@throws \Minime\Annotations\ParserException
@return mixed
766470
public function parse($value, $annotation = null)
    {
        $json = static::jsonDecode($value);
        if (JSON_ERROR_NONE != json_last_error()) {
            throw new ParserException("Raw value must be a valid JSON string. Invalid value '{$value}' given.");
        }

        return $json;
    }
546290
public function filter($value)
    {
        if (!is_string($value) && !is_array($value)) {
            return $value;
        }
        $result = @preg_replace($this->search, $this->replacement, $value);
        if ($result === null) {
            throw new FilterErrorException('An error occurred executing RegexReplace filter');
        }

        return $result;
    }
260937
public function filter($value)
    {
        if (!is_string($value)) {
            return $value;
        }

        // Strip unicode bombs, and make sure all newlines are UNIX newlines.
        $value = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $value);
        $value = preg_replace('{\r\n?}', "\n", $value);

        $lambda = function($text) {
            $text = htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
            /** @noinspection NotOptimalRegularExpressionsInspection */
            $text = preg_replace('/--/', '&mdash;', $text);
            $text = nl2br($text, false);
            $text = sprintf('<p>%s</p>', $text);

            return $text;
        };

        $paragraphs = preg_split('/\n{2,}/', $value, -1, PREG_SPLIT_NO_EMPTY);
        $paragraphs = array_map($lambda, $paragraphs);

        return implode("\n\n", $paragraphs);
    }
535035
protected function castAttributeAsJson($value)
    {
        $value = $this->asJson($value);

        if ($value === false) {
            throw new RuntimeException('Error encoding model ['.get_class($this).'] to JSON: '.json_last_error_msg());
        }

        return $value;
    }
928076
public function filter($value)
    {
        if (empty($value) && isset($this->filterData[$this->fieldToSlugFrom])) {
            $value = $this->filterData[$this->fieldToSlugFrom];
        }

        if (is_null($value)) {
            return $this->setEmpty();
        }

        $value = transliterator_transliterate($this->transliterator, $value);
        $value = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $value);
        $value = preg_replace('/[^\w\d]+/', '-', $value);
        $value = trim($value, '-');
        return strtolower($value);
    }
293228
public function sanitize($value)
    {
        $value = (string) $value;

        if (!empty($value)) {
            $value = JComponentHelper::filterText($value);
        }

        return $value;
    }
823678
private static boolean toBeIgnoredByJackson(@Nullable Annotation[] annotations) {

		return annotations == null //
				? false
				: Arrays.stream(annotations) //
						.filter(annotation -> annotation.annotationType().equals(JsonIgnore.class)) //
						.findFirst() //
						.map(annotation -> (Boolean) AnnotationUtils.getAnnotationAttributes(annotation).get("value")) //
						.orElse(false);
	}
1053989
public function convertJsonToArray($value) {

		if(true === $this -> convert_json) {

			if(true === is_string($value)) {

				$tmp = @json_decode($value, true);

				if(true === (json_last_error() == JSON_ERROR_NONE)) {
					$value = $tmp;
				}
			}
		}

		return $value;
	}
1355551
public function filter($value)
    {
        $filtered = parent::filter($value);
        return null === $filtered ? false : $filtered;
    }
1143471
public function unserialize($value)
    {
        $this->reset();
        $data = json_decode($value, true);
        if ($data === null && json_last_error() != JSON_ERROR_NONE) {
            throw new JsonSerializerException('Invalid JSON to unserialize.');
        }

        if (mb_strpos($value, static::UTF8ENCODED_IDENTIFIER_KEY) !== false) {
            $data = $this->decodeNonUtf8FromUtf8($data);
        }

        return $this->unserializeData($data);
    }
1273965
public function filter($value)
    {
        if (!is_scalar($value)) {
            return $value;
        }
        $value = (string) $value;

        $defaultScheme = $this->defaultScheme ?: $this->enforcedScheme;

        // Reset default scheme if it is not a known scheme
        if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) {
            $defaultScheme = null;
        }

        try {
            $uri = UriFactory::factory($value, $defaultScheme);
            if ($this->enforcedScheme && (!$uri->getScheme())) {
                $this->enforceScheme($uri);
            }
        } catch (UriException $ex) {
            // We are unable to parse / enfore scheme with the given config and input
            return $value;
        }

        $uri->normalize();

        if (!$uri->isValid()) {
            return $value;
        }

        return $uri->toString();
    }
1247004
public function filter($value)
    {
        if ($value instanceof VisibilityInterface
            && !$this->builder->isVisibilityAllowed($value->getVisibility())
        ) {
            return null;
        }

        return $value;
    }
91537
public function consumeAnnotationToken(string $value): void
    {
        if ($this->currentAnnotation === null) {
            // We are not in an annotation, build a new one.
            $this->currentAnnotation = $this->annotationFactory
                ->invoke($value, $this->currentLine);
        } else {
            if ($this->currentAnnotationContent === null) {
                // It is an annotation without content, save it and create the new one.
                $this->parsedAnnotations[] = $this->currentAnnotation;
                $this->reset();
                $this->currentAnnotation = $this->annotationFactory
                    ->invoke($value, $this->currentLine);
            } else {
                // An annotation content parsing is not finished.
                throw new AnnotationParseException(
                    'An annotation content is not closed (you probably forget to close a parenthesis or a quote)'
                );
            }
        }
    }
15260
public function filter($value) {
    	    	
    	$value   = str_replace(["\r", "\r\n", "\n"], '', $value);
    	$decoded = json_decode($value,true);
    	if(is_null($decoded)){
    		return null;
    	}    	
    	
    	switch($this->options["format"]){
    	    case self::DECODED:
    	        return $decoded;
    	    case self::JSON:
    	        return $value;
    	    case self::SERIALIZED:
    	        return serialize($decoded);
    	    default:
    	        throw new FilterException("unknown format for JSON filter specified");
    	}
    }
953766
protected function handleJsonType($value)
    {
        if (($repo = $this->getRepository())) {
            if (($cast = array_get($repo->getCasts(), $this->name)) && in_array($cast, ['array', 'json'], true)) {
                $value = json_encode($value);
            }
        }

        return $value;
    }
277859
protected function hydrateValue($value, PropertyAnnotation $annotation)
    {
        if ($annotation->type) {
            try {
                $value = $this->castProperty($annotation, $value);
            } catch (\Exception $e) {
                if ($annotation->isNullable()) {
                    $value = null;
                } else {
                    throw $e;
                }
            }
        }
        return $value;
    }
1222027
public static function decode($value)
    {
        if (empty($value)) {
            return null;
        }

        if (!is_string($value)) {
            throw new \InvalidArgumentException(sprintf(
                "Value type '%s' is not a PHP string so it cannot be unserialized.",
                gettype($value)
            ));
        }

        $data = unserialize($value);

        return $data;
    }