Remove the leading and trailing strings of json data

ask your bosses, how can such json data be elegantly parsed with python. Remove the head and tail?

Mar.14,2021

regular bar re


this is not a data in json format, but more like a text in js format. If it is a file demo.js , you can go like this:

import json

with open('demo.js', 'r') as file:
    lines = file.read().splitlines()
    -sharp 23, '{}'
    data = '{%s}' % ''.join(lines[2:-2])
    print(json.loads(data))
Menu