Depending on the shell you use, the escaping rules are different. Here you'll find examples of correct escaping and quotes when passing JSON objects on the command line using different shells.
The table below gives an overview of the escaping rules in these commonly used shells. VALUE refers to one single line in json.
Shell |
Correct Escaping and Quotes |
---|---|
Bash |
Use or Use |
Windows Command Prompt |
Use |
Windows PowerShell |
Use |
The CLI client provides examples in the command help for all commands. The examples that include JSON parameters use formatting that is compliant with Bash (Unix/Linux operating system, macOS) and Windows Command Prompt.
The command-line examples in this chapter are based on the following JSON:
{
"Key1": ["Value1"],
"Key2": ["Value1", "Value2"]
}
Option 1
--parameter "{\"Key1\":[\"Value1\"],\"Key2\":[\"Value1\", \"Value2\"]}"
For example, when creating a subaccount (btp create accounts/subaccount
) with labels Department
= Sales and Contacts
= name1@example.com and name2@example.com, use the following syntax:
btp create account/subaccount --display-name "my-subaccount" --region us10 --subdomain "my-subdomain" --labels "{\"Department\":[\"Sales\"],\"Contacts\":[\"name1@example.com\", \"name2@example.com\"]}"
Option 2
--parameter '{"Key1": ["Value1"], "Key2": ["Value1", "Value2"]}'
For example, when creating a subaccount (btp create accounts/subaccount
) with labels Department
= Sales and Contacts
= name1@example.com and name2@example.com, use the following syntax:
btp create account/subaccount --display-name "my-subaccount" --region us10 --subdomain my-subdomain --labels '{"Department": ["Sales"],"Contacts": ["name1@example.com", "name2@example.com"]}'
--parameter "{\"Key1\":[\"Value1\"],\"Key2\":[\"Value1\", \"Value2\"]}"
For example, when creating a subaccount (btp create accounts/subaccount
) with labels Department
= Sales and Contacts
= name1@example.com and name2@example.com, use the following syntax:
btp create account/subaccount --display-name "my-subaccount" --region us10 --subdomain "my-subdomain" --labels "{\"Department\":[\"Sales\"],\"Contacts\":[\"name1@example.com\", \"name2@example.com\"]}"
--parameter '{\"Key1\":[\"Value1\"],[\"Key2\":\"Value1\", \"Value2\"]}'
For example, when creating a subaccount (btp create accounts/subaccount
) with labels Department
= Sales and Contacts
= name1@example.com and name2@example.com, use the following syntax:
./btp create account/subaccount --display-name "my-subaccount" --region us10 --subdomain my-subdomain --labels '{\"Department\":[\"Sales\"],\"Contacts\":[\"name1@example.com\", \"name2@example.com\"]}'
You can also transfer JSON parameters by providing the full path to a JSON file. For example:
btp create services/binding --name my-binding-name --instance-name my-service-instance-name --parameters "<your-user-directory>/Documents/parameters.json"
Related Information
Working with Global Accounts, Directories, and Subaccounts Using the btp CLI