Skip to main content

JsonObject

JSON formatted object argument.

Attributes​

AttributeTypeDescription
namestring = json objectThe display name of the parameter type used for error messages and help text.

Methods​


convert()​

@classmethod
def convert(
value: any,
param: click.Parameter,
ctx: click.Context
) - > dict

Parses a JSON-formatted string into a Python dictionary or returns the value directly if it is already a dictionary. This method ensures the input represents a valid JSON object and raises a failure if the parsing fails or if the resulting data is not a dictionary.

Parameters​

NameTypeDescription
valueanyThe raw input value to be converted, typically a JSON-encoded string or an existing dictionary.
paramclick.ParameterThe parameter object that this value is being associated with during argument parsing.
ctxclick.ContextThe current execution context for the command line interface.

Returns​

TypeDescription
dictThe parsed JSON object as a Python dictionary.