Skip to main content

JSOB: Fault tolerant JSON parser. A standardization of low standards. Be a JSLOB.

Project description

JSONofabitch

  • fault tolerant json parser
  • JSON correction/formatting engine
  • stochastic ascii structured data format
  • a standard for low standards
  • the retard proof multi-parameter, multi-type input parser
  • a troll of api scraping reverse engineers
  • a JSON of a bitch!

functions

  • loads() - loads JSLOB compliant text
  • dumps() - dumps regular JSON
  • correct() - turns JSLOB to JSON
  • dumpslob() - dumps stochastic JSLOB

install

pip3 install jsonofabitch

build requires lark but jsonofabitch is stand-alone

JSLOB syntax

  • keypairs - : or = separate key value pairs, whitespace is ignored 'g=5' -> {"g": 5} and 'g:5' -> {"g": 5}, such keypairs are implicitly assumed to be in a JSLOB object which resolves to a python dict
  • keys - double quoted string or alphanumeric plus underscore, non-numeric first character(same as python vars).
  • values - another JSLOB object, a tupple, a list, alphanumeric string without quotes, quote-enclosed string, boolean true false , null , integers, floats
  • 'true' -> True 'false' -> False 'null' -> None case sensitive
  • tuples in ( ) lists in [ ] objects separated by comma , or semicolon ; . trailing comma/semicolon okay
  • dicts/JSLOB objects have keypairs separated by semicolon or comma, nested jslob objects(in lists, tuples or jslob objects) are terminated and separated simultaneously by ;; or ,, , IE: '[g=5,h=3]' -> [{'g': 5, 'h': 3}] and '[g=5;;h=3]' -> [{'g': 5}, {'h': 3}]
  • other - unquoted strings must be alphanumeric plus _ non-numeric first character. only double quotes can be used
  • scientific notation 2e4 resolves to $2.0 * 10^4$, always resolve to float
  • numbers with decimal present resolve to floats while others resolve to ints IE '3.0' -> 3.0 and '3' -> 3 '3.' -> 3.0

about/conventions

  • the parser is called JSOB(jay-sawb) in polite company
  • the standardized syntax is called JSLOB (jay-slawb)
  • suggested file extension .jslob or .slob or .jsob
  • the underlying parser is built using lark which generates stand-alone python from the lark meta-langauge that defines the grammar

changelog

  • version 0.3.0 transitioned from using the parseing library lark at runtime to a stand-alone parser generated by lark at build

examples

import jsonofabitch as jsob
d = jsob.loads("f=5, size=big, style=SLOB, coord=[(3,4),(1.2,3)]")
#{'f': 5, 'size': 'big', 'style': 'SLOB', 'coord': [(3, 4), (1.2, 3)]}

jsob.dumps(d)
#Out[3]: '{"f": 5, "size": "big", "style": "SLOB", "coord": [[3, 4], [1.2, 3]]}'

jsob.dumpslob(d)
#Out[4]: ' "f"=  5;  "size"="big";style=  "SLOB";  coord: [ (3 ,4 ), (1.2, 3,)  ];'

jsob.dumpslob(d)
#Out[5]: ' "f"= 5;size="big", style: SLOB, "coord": [ (3, 4 ),(1.2 , 3  ) ];'

jsob.dumpslob(d)
#Out[6]: ' "f"= 5,  size=  "big",style=  "SLOB";  coord:  [ (3,4 ,) ,(1.2 , 3,)  ];'

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

jsonofabitch-0.3.1.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

jsonofabitch-0.3.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file jsonofabitch-0.3.1.tar.gz.

File metadata

  • Download URL: jsonofabitch-0.3.1.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for jsonofabitch-0.3.1.tar.gz
Algorithm Hash digest
SHA256 09c2872ba95cf23e916454fa1885dff04b98fad90ec866351b310d410b26f29d
MD5 4728a5582de689dd1a64c480156fbc2e
BLAKE2b-256 b7a3a23320fb5682e1e3a9141379aa05d979a29dbb74fb917390cb38c5797250

See more details on using hashes here.

File details

Details for the file jsonofabitch-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: jsonofabitch-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for jsonofabitch-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 313a5bd5bf34f5ffdcbeb84fbbd50fcdf06c125cc1c308c8926334aa590a3b29
MD5 9b0a542287b1df133bb472188172efb9
BLAKE2b-256 2e62980f6554ace798b0cdaf43a52d1dc729ccde5b4c5d66d724e1c6755bf53d

See more details on using hashes here.

Supported by

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