Module ds.parsers.package_json

package.json parser.

Functions

def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)

Deserialize s (a str, bytes or bytearray instance containing a JSON document) to a Python object.

object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).

object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also defined, the object_pairs_hook takes priority.

parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).

parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).

parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.

To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.

def parse_workspace(config: Config, key: str = 'workspaces') ‑> Dict[pathlib.Path, bool]

package.json workspaces are in workspaces.

def parse_tasks(config: Config, key: str = 'scripts') ‑> Dict[str, Task]

package.json tasks are in scripts.

Features: - Supported (non-standard): disabled task - Supported (non-standard): task.help - task description - Supported: task.cmd - basic task - Supported (non-standard): task.args - argument interpolation - Not Supported: task.cwd - working directory - Supported (partial): task.depends - composite task (pre/post only) - Not Supported: task.env - environments - Not Supported: task.keep_going - error suppression