Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/render/html/env/strings.py: 0%
11 statements
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
« prev ^ index » next coverage.py v7.6.3, created at 2024-10-16 22:16 +0000
1import json
2import typing as t
4from ..utils import jinjaGlobalFilter
5from ..default import Render
8@jinjaGlobalFilter
9def parseJSON(render: Render, value: str) -> t.Any:
10 """
11 Jinja2 filter: Parses a JSON-string into a python object.
13 :param render: The html-renderer instance.
14 :param value: The string to be parsed.
15 :return: The parsed python object. \
16 Returns None if no JSON could be parsed.
17 """
18 try:
19 ret = json.loads(value)
20 except ValueError:
21 ret = None
23 return ret