(data)
| 24 | |
| 25 | |
| 26 | def content_to_json(data): |
| 27 | clean_data = re.sub(r'\[CONTENT\]|\[/CONTENT\]', '', data).strip() |
| 28 | |
| 29 | clean_data = re.sub(r'(".*?"),\s*#.*', r'\1,', clean_data) |
| 30 | |
| 31 | clean_data = re.sub(r',\s*\]', ']', clean_data) |
| 32 | |
| 33 | clean_data = re.sub(r'\n\s*', '', clean_data) |
| 34 | |
| 35 | |
| 36 | # JSON parsing |
| 37 | try: |
| 38 | json_data = json.loads(clean_data) |
| 39 | return json_data |
| 40 | except json.JSONDecodeError as e: |
| 41 | # print(e) |
| 42 | return content_to_json2(data) |
| 43 | |
| 44 | |
| 45 | def content_to_json2(data): |
no test coverage detected