Working with JSON Input in DCLI

You can provide JSON input for single options or for a whole command.

Providing JSON Input for Single Options

Input for maps and lists of structures in DCLI must be provided by using the JSON format. You can provide the input either directly to the console or by using a .json file.

You can use the following syntax to provide JSON command input directly to the console.

dcli com vmware vcenter sample command --map ‘{“key1”:”value”,”key2”:”value”}’
Note: You must not use blank spaces between the JSON elements.

You can use the following syntax to provide JSON command input by using a .json file.

dcli com vmware vcenter sample command --map /path/to/json_file.json

Providing JSON Input for a Whole Command

DCLI provides the option to generate empty command input in JSON format. After generating the empty command input, you can populate the empty fields with custom input values. You must remove any unnecessary fields from the generated content. After you populate the empty fields, you can provide the content back as command input.

You can use the following syntax to generate empty JSON command input.

dcli com vmware sample command +generate-json-input

You can use the following syntax to generate empty JSON command input for required fields only.

dcli com vmware sample command +generate-required-json-input

You can use the following syntax to generate empty JSON command input and save it as a file, which you can populate later.

dcli com vmware sample command +generate-json-input > json_input.json

You can use the following syntax to provide JSON command input by using a .json file that you have populated.

dcli com vmware sample command +json-input json_input.json

You can use the following syntax to provide JSON command input directly to the console.

dcli com vmware sample command +json-input ‘{“option”:”value”}’
Note: You must not use blank spaces between the JSON elements.