KISSmetrics generates invalid JSON strings I need to parse. I'm getting tons of errors like
ERROR 2013-03-04 04:31:12,253 Invalid escape: line 1 column 132 (char 132): {"search engine":"Google","_n":"search engine hit","_p":"z392cpdpnm6silblq5mac8kiugq=","search terms":"happy new year animation 19203032271080 hd","_t":1356390128}
ERROR 2013-03-04 04:34:19,153 Invalid escape: line 1 column 101 (char 101): {"search engine":"Google","_n":"ad campaign hit","_p":"byskpczsw6sorbmzqi0tk1uimgw=","search terms":"331203330261330252331207 331201331212330257331212330244331211 330256331212331204330247330255331211 331203331210330261330257331211","_t":1356483052}
My code is:
for line in lines:
try:
data = self.clean_data(json.loads(line))
except ValueError, e:
logger.error('%s: %s' % (e.message, line))
Example raw data:
{"search engine":"Google","_n":"search engine hit","_p":"kvceh84hzbhywcnlivv+hdztizw=","search terms":"military sound effects programs","_t":1356034177}
Is there any chance to cleanup this messy JSON and parse it? Thanks for your help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…