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 _-~$@&?.%<>#!^+/*(no spaces,no unicode) non-numeric first character.
  • values - another JSLOB object, a tupple, a list, 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}]
  • strings - same as keys, mostly only need quotes for numeric first character or if it includes spaces.
  • 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

  • 0.4.0 - add support for a wider range of characters in unquoted strings
  • 0.3.5 - fix handling of empty lists, tuples, improve approach to handling empty JSLOB objects
  • 0.3.2 - fix improper handling of None and bools by dumps functions
  • 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.4.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

jsonofabitch-0.4.0-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jsonofabitch-0.4.0.tar.gz
Algorithm Hash digest
SHA256 bb6f1feedbbba9c2fdfca3547e75d43167beec55bdce5a473e1438eeaf857b8c
MD5 3348d59667b6a571e9ac5f5759004b79
BLAKE2b-256 630d6528a8b702d427c7f8edb8205b2fbd2258909554257f6890d21ea4254671

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonofabitch-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 36.1 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec0d7d0188ac351c35aa775fe93d7beb8e4b98ddc26f484918a99cf34d854f6b
MD5 d150fc933bbed9144a9517f9573a4062
BLAKE2b-256 df8ce40e38a4d59a98de456ed540ee41710875f2479caf7d730f8fb2bd3fef39

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