Skip to content

JSONC should support back-ticked strings (multi-line and less escaping) #172423

@codedread

Description

@codedread

tasks.json should support back-ticked strings as values to help with multi-line commands and quote-escaping. This is an alternative to issue #168102 and could go a long way to making Tasks even more powerful.

tasks.json is already not valid JSON since it supports a) comments and b) trailing commas. These are 2 of 3 very useful improvements to JSON for using it as a config file format [1]. Back-ticked strings could allow multi-line strings and require less escaping for bash commands...

{
  "label": "cron enable dev",
  "type": "shell",
  "command": "kubectl patch cronjob cron-blah --type json -p '[{\"op\":\"replace\", \"path\":\"/spec/schedule\", \"value\":\"* * * * *\"}, {\"op\":\"replace\", \"path\":\"/spec/jobTemplate/spec/template/spec/containers/0/imagePullPolicy\", \"value\":\"Always\"}]'"
},

vs

{
  "label": "cron enable dev",
  "type": "shell",
  "command": `
    kubectl patch cronjob cron-blah --type json -p '[{ \
        "op":"replace", \
        "path":"/spec/schedule", \
        "value":"* * * * *" \
    }, {\
        "op":"replace", \
        "path":"/spec/jobTemplate/spec/template/spec/containers/0/imagePullPolicy", \
        "value":"Always" \
    }]'`
},

[1] http://www.codedread.com/blog/archives/2022/10/26/3-wishes-for-json/

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitytasksTask system issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions