Python Module
Python implementation of jsonurl, an alternative format for JSON data model
See https://jsonurl.org/ and https://github.com/jsonurl/specification/
- class jsonurl_py.CommonOpts(*, implied_list: bool = False, implied_dict: bool = False, distinguish_empty_list_dict: bool = False, aqf: bool = False)
Bases:
object
Common options for both
dumps
andloads
- distinguish_empty_list_dict: bool = False
Distinguish between empty list and empty dict
Use
(:)
for empty dict and()
for empty list as per spec section 2.9.5
- aqf: bool = False
Address bar Query string Friendly
Use
!
quoting instead of'
as per spec section 2.9.6
- class jsonurl_py.DumpOpts(*, implied_list: bool = False, implied_dict: bool = False, distinguish_empty_list_dict: bool = False, aqf: bool = False, safe: str = '')
Bases:
CommonOpts
Options for
jsonurl_py.dumps
- safe: str = ''
Additional characters considered safe and not requiring percent-encoding.
This is similar to the safe argument to
urllib.parse.quote_plus
.By default only the characters
[a-zA-Z0-9_.-~]
are safe. Additional characters that can be marked safe are:!$*/;?@
. In AQF mode the characters “’” can also be marked as safe.In AQF mode the characters
(),:
are considered safe by default so that output is readable but on input they are also recognized in encoded form.
- jsonurl_py.dumps(arg: Any, opts: DumpOpts | None = None) str
- jsonurl_py.dumps(arg: Any, *, implied_list: bool = False, implied_dict: bool = False, aqf: bool = False, safe: str = '', distinguish_empty_list_dict: bool = False) str
Convert a json object into a jsonurl string
Options can be passed as a
DumpOpts
object or as individual keyword arguments.
- jsonurl_py.check_can_mark_safe(safe: str, aqf=False)
Check if a string can be marked as safe for jsonurl
- class jsonurl_py.LoadOpts(*, implied_list: bool = False, implied_dict: bool = False, distinguish_empty_list_dict: bool = False, aqf: bool = False)
Bases:
CommonOpts
Options for
loads
method
- jsonurl_py.loads(arg: str, opts: LoadOpts | None = None) Any
- jsonurl_py.loads(arg: str, *, implied_dict: bool = False, implied_list: bool = False, aqf: bool = False, distinguish_empty_list_dict: bool = False) Any
Convert a json object into a jsonurl string
Options can be passed as a
LoadOpts
object or as individual keyword arguments.
- jsonurl_py.create_parser()
- jsonurl_py.main(argv=None)
Command Line
Python implementation of jsonurl, an alternative format for JSON data model
See https://jsonurl.org/ and https://github.com/jsonurl/specification/
usage: jsonurl-py [-h] SUBCMD ...
Positional Arguments
- SUBCMD
Possible choices: load, dump
Sub-commands
load
Parse JSONURL input and output JSON
jsonurl-py load [-h] [-l] [-d] [-a] [--indent INDENT]
Named Arguments
- -l, --implied-list
Implied Array mode
Default:
False
- -d, --implied-dict
Implied Object mode
Default:
False
- -a, --address-query-friendly
Address Bar Query String Friendly mode
Default:
False
- --indent
Output indent spaces per level
dump
Parse JSON input and output JSONURL
jsonurl-py dump [-h] [-l] [-d] [-a]
Named Arguments
- -l, --implied-list
Implied Array mode
Default:
False
- -d, --implied-dict
Implied Object mode
Default:
False
- -a, --address-query-friendly
Address Bar Query String Friendly mode
Default:
False