Skip to content

Allow JSON array parameters in gh api #1484

@mislav

Description

@mislav

Neither --field nor --raw-field accept JSON arrays right now. To pass a JSON array or a nested object, one needs to construct the JSON payload outside of gh and pass it in via --input. E.g.

jq -n '...' | gh api repos/:owner/:repo/deployments --input -

I propose a new array syntax for fields:

# array of strings
-f labels[]=one labels[]=two

# empty array
-f required_contexts[]

# other value types
-F foo[]=true -F bar[]=null

This syntax would allow passing values of any type, including an empty array, and is fully backwards-compatible. The only theoretical drawback is that it would be impossible to pass a parameter name that includes the literal [] characters, but since no API parameters ever have [] characters in their name, I think this is not a concern.

Originally posted by @mislav in #921 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions