Relaxed, or best-efforts JSON parser for Python?

Victor Hooi victorhooi at gmail.com
Sun Oct 11 20:56:33 EDT 2015


Hi,

I'm attempting to parse MongoDB loglines.

The formatting of these loglines could best be described as JSON-like...

For example - arrays 

Anyhow, say I had the following logline snippet:

    { Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 1 } }, oplog: { acquireCount: { w: 1 } } }

This won't parse with json.loads() - the main issues is the missing quotation marks (") around the strings.

My question, is there a more lenient, or relaxed JSON parser available for Python, that will try to do a best-efforts parsing of non-spec JSON?

Cheers,
Victor



More information about the Python-list mailing list