Note

Click here to download the full example code

Transformer for evaluating json.lark

    from lark import Transformer, v_args

    class JsonTreeToJson(Transformer):
        @v_args(inline=True)
        def string(self, s):
            return s[1:-1].replace('\\"', '"')

        array = list
        pair = tuple
        object = dict
        number = v_args(inline=True)(float)

        null = lambda self, _: None
        true = lambda self, _: True
        false = lambda self, _: False

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery