mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-01-02 04:01:13 -05:00
In all the shuffling of these docs for v0.12 some of the links ended up not lining up quite right.
1.8 KiB
1.8 KiB
layout, page_title, sidebar_current, description
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| functions | jsondecode - Functions - Configuration Language | docs-funcs-encoding-jsondecode | The jsondecode function decodes a JSON string into a representation of its value. |
jsondecode Function
-> Note: This page is about Terraform 0.12 and later. For Terraform 0.11 and earlier, see 0.11 Configuration Language: Interpolation Syntax.
jsondecode interprets a given string as JSON, returning a representation
of the result of decoding that string.
The JSON encoding is defined in RFC 7159.
This function maps JSON values to Terraform language values in the following way:
| JSON type | Terraform type |
|---|---|
| String | string |
| Number | number |
| Boolean | bool |
| Object | object(...) with attribute types determined per this table |
| Array | tuple(...) with element types determined per this table |
| Null | The Terraform language null value |
The Terraform language automatic type conversion rules mean that you don't usually need to worry about exactly what type is produced for a given value, and can just use the result in an intuitive way.
Examples
> jsondecode("{\"hello\": \"world\"}")
{
"hello" = "world"
}
> jsondecode("true")
true
Related Functions
jsonencodeperforms the opposite operation, encoding a value as JSON.