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 transferred in a file instead of command line.

1) foo.json file:

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

Last update: July 6, 2023

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