You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7a11e87
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: website/docs/language/functions/format.mdx
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,23 @@ Hello, Valentina!
34
34
Hello, Valentina!
35
35
```
36
36
37
+
The formatting verb `%#v` accepts a value of any type and presents it using JSON encoding, similar to jsonencode. This can be useful for describing the values given to a module in [custom condition check](/language/expressions/custom-conditions#error-messages) error messages.
38
+
39
+
```
40
+
> format("%#v", "hello")
41
+
"\"hello\""
42
+
> format("%#v", true)
43
+
"true"
44
+
> format("%#v", 1)
45
+
"1"
46
+
> format("%#v", {a = 1})
47
+
"{\"a\":1}"
48
+
> format("%#v", [true])
49
+
"[true]"
50
+
> format("%#v", null)
51
+
"null"
52
+
```
53
+
37
54
The `format` function is most useful when you use more complex format specifications.
0 commit comments