github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/jsondecode.html.md (about)

     1  ---
     2  layout: "functions"
     3  page_title: "jsondecode - Functions - Configuration Language"
     4  sidebar_current: "docs-funcs-encoding-jsondecode"
     5  description: |-
     6    The jsondecode function decodes a JSON string into a representation of its
     7    value.
     8  ---
     9  
    10  # `jsondecode` Function
    11  
    12  -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
    13  earlier, see
    14  [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
    15  
    16  `jsondecode` interprets a given string as JSON, returning a representation
    17  of the result of decoding that string.
    18  
    19  The JSON encoding is defined in [RFC 7159](https://tools.ietf.org/html/rfc7159).
    20  
    21  This function maps JSON values to
    22  [Terraform language values](../expressions.html#types-and-values)
    23  in the following way:
    24  
    25  | JSON type | Terraform type                                               |
    26  | --------- | ------------------------------------------------------------ |
    27  | String    | `string`                                                     |
    28  | Number    | `number`                                                     |
    29  | Boolean   | `bool`                                                       |
    30  | Object    | `object(...)` with attribute types determined per this table |
    31  | Array     | `tuple(...)` with element types determined per this table    |
    32  | Null      | The Terraform language `null` value                          |
    33  
    34  The Terraform language automatic type conversion rules mean that you don't
    35  usually need to worry about exactly what type is produced for a given value,
    36  and can just use the result in an intuitive way.
    37  
    38  ## Examples
    39  
    40  ```
    41  > jsondecode("{\"hello\": \"world\"}")
    42  {
    43    "hello" = "world"
    44  }
    45  > jsondecode("true")
    46  true
    47  ```
    48  
    49  ## Related Functions
    50  
    51  * [`jsonencode`](./jsonencode.html) performs the opposite operation, _encoding_
    52    a value as JSON.