from_json

Parses a JSON object string into a map, so a serialized payload (an API response body, a config blob) becomes data that later template steps can index into.

Numbers decode to native int64 or float64 (a value with a decimal point or exponent becomes float64, otherwise int64) rather than json.Number, so downstream numeric modifiers see real numbers. A top-level JSON array or scalar is not an object and returns an error.

InputArgumentsReturnsstringno argumentsmap[string]any
Source
BasicSource

Parses a JSON object string into a map, so a serialized payload becomes data that later template steps can index into.

Given

{"body": "{\"name\": \"Alice\", \"role\": \"admin\"}"}

Template

{{ body | from_json }}

Result

{
  "name": "Alice",
  "role": "admin"
}
NestedSource

Parses a JSON object that contains a nested object and an array, keeping the structure intact for later indexing.

Given

{"body": "{\"user\": {\"id\": 7}, \"scores\": [1, 2.5]}"}

Template

{{ body | from_json }}

Result

{
  "scores": [
    1,
    2.5
  ],
  "user": {
    "id": 7
  }
}
NumbersSource

Shows that JSON numbers decode to native int64 and float64, so a value with a decimal point stays a float and downstream numeric modifiers see real numbers.

Given

{"body": "{\"count\": 3, \"ratio\": 1.5}"}

Template

{{ body | from_json }}

Result

{
  "count": 3,
  "ratio": 1.5
}