nbuilding/N-lang

`json.parse` will throw runtime error if property name is not enclosed in quotes

Ashvin-Ranjan opened this issue · 0 comments

Traceback (most recent call last):
  File "C:\Users\Ashvin\N\python\function.py", line 47, in run_command
    _, value = await scope.eval_command(self.codeblock)
  File "C:\Users\Ashvin\N\python\scope.py", line 1154, in eval_command
    exit, value = await self.eval_command(instruction)
  File "C:\Users\Ashvin\N\python\scope.py", line 1319, in eval_command
    expr = await self.eval_expr(assert_type.children[0])
  File "C:\Users\Ashvin\N\python\scope.py", line 922, in eval_expr
    return await self.eval_expr(left) == await self.eval_expr(right)
  File "C:\Users\Ashvin\N\python\scope.py", line 1040, in eval_expr
    return await self.eval_expr(token_or_tree)
  File "C:\Users\Ashvin\N\python\scope.py", line 892, in eval_expr
    return await func.run(arg_values)
  File "C:\Users\Ashvin\N\python\native_function.py", line 29, in run
    maybe_awaitable = self.function(*arguments)
  File "C:\Users\Ashvin\N\python\libraries\json.py", line 93, in parse
    return python_to_json(json.loads(string))
  File "C:\Users\Ashvin\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Ashvin\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Ashvin\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

This can be solved with a try except