diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-26 22:03:16 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-26 22:03:16 +0200 |
commit | 087b6c77a1e2cbb014bb19a4bed78a04336d51dc (patch) | |
tree | 3389bce95691f46cf4da11333f345207e0e72b24 /README.md | |
parent | 486ff859ced13c2454e7d12788069e5db30b618d (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.md | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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 ] %} ``` |