This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 regels
532 B

  1. import sys
  2. from json_parser import Lark_StandAlone, Transformer, inline_args
  3. class TreeToJson(Transformer):
  4. @inline_args
  5. def string(self, s):
  6. return s[1:-1].replace('\\"', '"')
  7. array = list
  8. pair = tuple
  9. object = dict
  10. number = inline_args(float)
  11. null = lambda self, _: None
  12. true = lambda self, _: True
  13. false = lambda self, _: False
  14. parser = Lark_StandAlone(transformer=TreeToJson())
  15. if __name__ == '__main__':
  16. with open(sys.argv[1]) as f:
  17. print(parser.parse(f.read()))