GitHub Actions toJSON / fromJSON Round-Trip Prints [object Object]
Interpolating a whole context object (like github.event or a matrix entry) into a string produces an unhelpful rendering, because GitHub expressions only stringify scalars cleanly. You need toJSON to serialize objects and fromJSON to parse them back.
What this error means
A step prints a useless or empty rendering of an object, or an expression errors, because a map/array was interpolated directly instead of being passed through toJSON (or parsed with fromJSON).
- run: echo "event is ${{ github.event }}"
# renders as "event is Object" / blank - needs toJSON(github.event)Common causes
Interpolating an object instead of a scalar
Expression interpolation expects a scalar. Dropping a whole object (github.event, a matrix row, steps.<id>.outputs) into a string does not serialize it usefully.
Skipping fromJSON when consuming JSON
A JSON string from an output or input must be parsed with fromJSON to access fields. Treating the raw string as an object yields empty property reads.
How to fix it
Serialize with toJSON, parse with fromJSON
Use toJSON to print or pass an object as JSON, and fromJSON to turn a JSON string back into an object you can index.
# print an object for debugging
- run: echo '${{ toJSON(github.event) }}'
# parse a JSON output then read a field
- run: echo "${{ fromJSON(steps.meta.outputs.json).tag }}"Keep object boundaries explicit
- Wrap any object you log or pass between steps in toJSON.
- Parse JSON inputs/outputs with fromJSON before accessing properties.
- Quote the toJSON output in shell so embedded quotes do not break the command.
How to prevent it
- Use toJSON to render or transport context objects.
- Use fromJSON to read fields out of a JSON string.
- Avoid interpolating raw objects directly into strings.