Skip to content

Commit

Permalink
Merge pull request #1941 from bolt/fix/add-missing-json-decode
Browse files Browse the repository at this point in the history
Add missing `json_decode` Twig Filter
  • Loading branch information
I-Valchev committed Oct 6, 2020
2 parents a2cbaff + e8637a1 commit b21bf8e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Twig/JsonExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getFilters()
return [
new TwigFilter('normalize_records', [$this, 'normalizeRecords']),
new TwigFilter('json_records', [$this, 'jsonRecords']),
new TwigFilter('json_decode', [$this, 'jsonDecode']),
];
}

Expand Down Expand Up @@ -113,4 +114,9 @@ public function testJson(string $string): bool
{
return Json::test($string);
}

public function jsonDecode(string $json, $assoc = false, $depth = 512, $options = 0)
{
return json::json_decode($json, $assoc, $depth, $options);
}
}

0 comments on commit b21bf8e

Please sign in to comment.