Spec-Zone.ru › OpenTofu 1.11

jsondecode Function

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 OpenTofu language values in the following way:

JSON type OpenTofu 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 OpenTofu language null value

The OpenTofu 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​

Code Block
> jsondecode("{\"hello\": \"world\"}")
{
  "hello" = "world"
}
> jsondecode("true")
true

Related Functions​

  • jsonencode performs the opposite operation, encoding a value as JSON.

Copyright (c) The OpenTofu Authors
Copyright (c) 2014 HashiCorp, Inc.
Mozilla Public License, version 2.0
https://opentofu.org/docs/v1.11/language/functions/jsondecode/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API