Skip to main content

A fast, simple parser for terribly broken JSON

Project description

JSOM - not quite JSON, but close enough

jsom is a simple and quick Python 3.7+ parser for terribly broken JSON.

Installation

$ pip install jsom

Usage

jsom works like this:

>>> import jsom
>>> broken_json = "{\"foo\": {bar: 1, 'baz':,}, bar: 1, baz: [1,2,3,],}")
>>> jsom.JsomParser(ignore_warnings=jsom.ALL_WARNINGS).loads(broken_json)
{'foo': {'bar': 1, 'baz': None}, 'bar': 1, 'baz': [1, 2, 3]}

jsom happily gobbles up the following:

  • unquoted keys and values
  • single-quoted strings
  • trailing commas
  • empty values in objects

By default, it will warn you whenever it sees one of those, but still parse it.

Warnings are annoying, though, and to make matters worse, they slow the parser down - so just pass in the list of warnings you want jsom to be quiet about in the ignore_warnings parameter:

parser = JsomParser(
    ignore_warnings=[jsom.SINGLE_QUOTED_STRING, jsom.EMPTY_OBJECT_VALUE]
)

Or, if you prefer, just tell it to shut up completely, by passing in jsom.ALL_WARNINGS.

LICENSE

jsom is distributed under the terms of the Do What The Fuck You Want To Public License (WTFPL):

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> 

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsom-0.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsom-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file jsom-0.0.1.tar.gz.

File metadata

  • Download URL: jsom-0.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for jsom-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b1fcd9335fd21dd148974e2519c30df9591b958682847b9863c40553df183cdc
MD5 c579052fbc976bdf2b372b6d52b40463
BLAKE2b-256 2ebed3c2973dfce7891cfb9e28ec894b3f668feb7e083ce964e65c102383c164

See more details on using hashes here.

File details

Details for the file jsom-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: jsom-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for jsom-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fff0213a35d45700dbed591631e0ecff48b6f7a72e020850bb18314ea3da138a
MD5 533a803d160f2138f3e7a53340c7930e
BLAKE2b-256 d55e20c8d79ec6f99f948319f342979d2accfafea391638f8028f64f19047e3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page