https://github.com/benlei/json2outputs
This action will read in a JSON body / file and set them as outputs
https://github.com/benlei/json2outputs
github-actions json workflows
Last synced: about 1 month ago
JSON representation
This action will read in a JSON body / file and set them as outputs
- Host: GitHub
- URL: https://github.com/benlei/json2outputs
- Owner: benlei
- License: mit
- Created: 2024-09-22T16:53:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-05-18T03:30:46.000Z (about 2 months ago)
- Last Synced: 2026-05-18T05:42:05.087Z (about 2 months ago)
- Topics: github-actions, json, workflows
- Language: TypeScript
- Homepage:
- Size: 856 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# benlei/json2outputs

[](https://github.com/benlei/json2outputs/actions/workflows/check-dist.yml)
[](https://github.com/benlei/json2outputs/actions/workflows/codeql-analysis.yml)
[](./badges/coverage.svg)
Reads in a `json` input (or `file` input) and tries to output its values in dot
notation. Note that if the json/file is a primitive/missing/has errors, nothing
will be output.
For example given the JSON:
```json
{
"foo": {
"bar": [1, 2, 3]
},
"hello": {
"world": "abc",
"example.com/foobar": "bye",
"yes": true,
"no": false
}
}
```
Should output the following:
- `steps.my-id.outputs['foo.bar[0]'] = '1'`
- `steps.my-id.outputs['foo.bar[1]'] = '2'`
- `steps.my-id.outputs['foo.bar[2]'] = '3'`
- `steps.my-id.outputs['hello.world'] = 'abc'`
- `steps.my-id.outputs['hello["example.com/foobar"]'] = 'bye'`
- `steps.my-id.outputs['hello.yes'] = 'true'`
- `steps.my-id.outputs['hello.no'] = 'false'`
## Inputs
| Input Name | Required | Default | Description |
| ---------- | -------- | ------- | ---------------------------------------------------------------- |
| `json` | no | `''` | The JSON body (string) to parse |
| `file` | no | `''` | The JSON file to parse. Ignored if `json` has a non-empty value. |
## Outputs
Varies depending on inputs.
## Examples
### Passing in a raw JSON body
```yaml
- name: Test
id: json
uses: benlei/json2outputs@v1
with:
json: |
{
"foo": {
"bar": [1, 2, 3]
},
"hello": {
"world": "abc",
"example.com/foobar": "bye",
"yes": true,
"no": false
}
}
- name: Output value:
run: |
echo ${{ steps.json.outputs['hello["example.com/foobar"]'] }}
```
### Passing in a JSON file
```yaml
- name: Test
id: json
uses: benlei/json2outputs@v1
with:
file: ./some.json
- name: Output value:
run: |
echo ${{ steps.json.outputs['hello["example.com/foobar"]'] }}
```