#!/usr/bin/env python3
import re, sys
sys.stdout.reconfigure(encoding='utf-8')

raw = open(r'E:\ios\work319\apps.json', 'rb').read()
if raw[:2] in (b'\xff\xfe', b'\xfe\xff'):
    s = raw.decode('utf-16')
else:
    s = raw.decode('utf-8-sig', errors='replace')

lines = s.splitlines()
hits = [i for i, l in enumerate(lines) if '"CFBundleDisplayName": "LCSign"' in l]
print('hits', len(hits))
for i in hits:
    key = None
    for j in range(i, -1, -1):
        m = re.match(r'^    "(.+?)": \{$', lines[j])
        if m:
            key = m.group(1)
            break
    print('---', key)
    for j in range(i, min(i + 500, len(lines))):
        l = lines[j]
        if any(k in l for k in ('CFBundleIdentifier', 'CFBundleShortVersionString',
                                '"Path"', 'DataContainer', 'Container', 'ApplicationType',
                                'CFBundleVersion', 'CFBundleExecutable')):
            print('   ', l.strip())
        if re.match(r'^    \},?$', l):
            break
