summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-26 22:03:16 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-26 22:03:16 +0200
commit087b6c77a1e2cbb014bb19a4bed78a04336d51dc (patch)
tree3389bce95691f46cf4da11333f345207e0e72b24 /README.md
parent486ff859ced13c2454e7d12788069e5db30b618d (diff)
lib: implement '%J' printf format
The `%J` format allows outputting values as valid JSON string. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'README.md')
-rw-r--r--README.md4
1 files changed, 4 insertions, 0 deletions
diff --git a/README.md b/README.md
index 74ea217..07b384f 100644
--- a/README.md
+++ b/README.md
@@ -873,6 +873,9 @@ Utpl supports a restricted subset of the formats allowed by the underlying
libc's `printf()` implementation, namely it allows the `d`, `i`, `o`, `u`, `x`,
`X`, `e`, `E`, `f`, `F`, `g`, `G`, `c` and `s` conversions.
+Additionally, an utpl specific `J` format is implemented, which causes the
+corresponding value to be formatted as JSON string.
+
Other format specifiers such as `n` or `z` are not accepted and returned
verbatim. Format specifiers including `*` and `$` directives are rejected as
well.
@@ -883,6 +886,7 @@ well.
printf("%08x\n", 123); // 0000007b
printf("%c%c%c\n", 65, 98, 99); // Abc
printf("%g\n", 10 / 3.0); // 3.33333
+ printf("%J", [1,2,3]); // [ 1, 2, 3 ]
%}
```