Skip to content

Ensure that cli JSON output always return a JsonObject  #2406

Closed
@alessio-perugini

Description

@alessio-perugini

Describe the request

Right now there are some commands like arduino-cli core list --format json that return an array of objects.
When a cli command is requested with the --format json, we want to enforce the output to start with a JSON object.
This also helps when we need to add some warning information in the JSON output, and it would simply add a warnings key in the object avoiding inconsistent behavior or some fatal edge cases.

We should also double-check if there are some commands that should return some json object but it currently doesn't return anything.

Expectation:
The result key can have also a different name. Something to be decided during the implementation.

arduino-cli core list --format json
{
  "result":[{...},...,{...}]
}

Describe the current behavior

Currently some commands like arduino-cli core list --format json print an array of objects

[
{...},
{...}
]

Arduino CLI version

Operating system

Linux

Operating system version

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the nightly build
  • My request contains all necessary details

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions