|
| 1 | +Flux API functions that are based on Jansson's :func:`json_pack` |
| 2 | +accept the following tokens in their format string. |
| 3 | +The type in parenthesis denotes the resulting JSON type, and |
| 4 | +the type in brackets (if any) denotes the C type that is expected as |
| 5 | +the corresponding argument or arguments. |
| 6 | + |
| 7 | +**s** (string)['const char \*'] |
| 8 | + Convert a null terminated UTF-8 string to a JSON string. |
| 9 | + |
| 10 | +**s?** (string)['const char \*'] |
| 11 | + Like **s**, but if the argument is NULL, outputs a JSON null value. |
| 12 | + |
| 13 | +**s#** (string)['const char \*', 'int'] |
| 14 | + Convert a UTF-8 buffer of a given length to a JSON string. |
| 15 | + |
| 16 | +**s%** (string)['const char \*', 'size_t'] |
| 17 | + Like **s#** but the length argument is of type size_t. |
| 18 | + |
| 19 | +**+** ['const char \*'] |
| 20 | + Like **s**, but concatenate to the previous string. |
| 21 | + Only valid after a string. |
| 22 | + |
| 23 | +**+#** ['const char \*', 'int'] |
| 24 | + Like **s#**, but concatenate to the previous string. |
| 25 | + Only valid after a string. |
| 26 | + |
| 27 | +**+%** ['const char \*', 'size_t'] |
| 28 | + Like **+#**, but the length argument is of type size_t. |
| 29 | + |
| 30 | +**n** (null) |
| 31 | + Output a JSON null value. No argument is consumed. |
| 32 | + |
| 33 | +**b** (boolean)['int'] |
| 34 | + Convert a C int to JSON boolean value. Zero is converted to |
| 35 | + *false* and non-zero to *true*. |
| 36 | + |
| 37 | +**i** (integer)['int'] |
| 38 | + Convert a C int to JSON integer. |
| 39 | + |
| 40 | +**I** (integer)['int64_t'] |
| 41 | + Convert a C int64_t to JSON integer. |
| 42 | + Note: Jansson expects a json_int_t here without committing to a size, |
| 43 | + but Flux guarantees that this is a 64-bit integer. |
| 44 | + |
| 45 | +**f** (real)['double'] |
| 46 | + Convert a C double to JSON real. |
| 47 | + |
| 48 | +**o** (any value)['json_t \*'] |
| 49 | + Output any given JSON value as-is. If the value is added to an array |
| 50 | + or object, the reference to the value passed to **o** is stolen by the |
| 51 | + container. |
| 52 | + |
| 53 | +**O** (any value)['json_t \*'] |
| 54 | + Like **o**, but the argument's reference count is incremented. This |
| 55 | + is useful if you pack into an array or object and want to keep the reference |
| 56 | + for the JSON value consumed by **O** to yourself. |
| 57 | + |
| 58 | +**o?**, **O?** (any value)['json_t \*'] |
| 59 | + Like **o** and **O**, respectively, but if the argument is NULL, |
| 60 | + output a JSON null value. |
| 61 | + |
| 62 | +**[fmt]** (array) |
| 63 | + Build an array with contents from the inner format string. **fmt** may |
| 64 | + contain objects and arrays, i.e. recursive value building is supported. |
| 65 | + |
| 66 | +**{fmt}** (object) |
| 67 | + Build an object with contents from the inner format string **fmt**. |
| 68 | + The first, third, etc. format specifier represent a key, and must be a |
| 69 | + string as object keys are always strings. The second, fourth, etc. |
| 70 | + format specifier represent a value. Any value may be an object or array, |
| 71 | + i.e. recursive value building is supported. |
| 72 | + |
| 73 | +Whitespace, **:** (colon) and **,** (comma) are ignored. |
| 74 | + |
| 75 | +These descriptions came from the Jansson 2.9 manual. |
| 76 | + |
| 77 | +See also: Jansson API: Building Values: http://jansson.readthedocs.io/en/2.9/apiref.html#building-values |
0 commit comments