Skip to content

Cloud Foundry How Tos - Updating service with json object in custom parameter

Escape quotes of json objects in command line

There are differences in escaping quotes of json objects in command line. The following example shows the correct escaping for Linux / Mac, Windows Command Line and Windows PowerShell.

  • Linux / Mac:
    cf update-service <servicename> -c '{"update": true}'
  • Windows Command Line:
    cf update-service <servicename> -c "{\"update\": true}"
  • Windows PowerShell:
    cf update-service <servicename> -c '{\"update\": true}'

Transfer json in file

To avoid quote escaping issues, the custom parameter in json format can also be transerred in a file instead of command line.

Example:
1) foo.json file:

{
  "update": true
}
2) cf update-service <servicename> -c foo.json

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the Development License Agreement.


Last update: July 14, 2020