| Spread RPC - Reference Manual |
|---|
Builder SyntaxBuilder Syntax — Format Strings for the sp_rpc_value_builder function |
The following table describes all of the simple format specifiers. A format string consists of either a single simple format specifier or a single compound format specifier. The next section covers compound format specifiers.
Specifier SPRpcValue type
n null
d double precision floating point number
b boolean
s null-terminated UTF-8 string
s# UTF-8 pointer/length string
(values) array of values
{s:value,s:value} struct of key/values. key is always a string
i
A simple integer
s
A string
(iii)
Array of 3 integers
{s:i,s:d}
Structure with two elements. The first has a string for a name (true of any SpreadRPC structure) and an integer for a value. The second has a string for a name and a floating point number for a value.
{s:i,s:(ss{s:s,s:d})}
A structure whose first element has a string for a name and an integer for a value, and whose second element has a string for a name and an array for a value. That array's first two elements are strings. Its third element is a structure. That structure has two elements, both named by strings. The value of the first is a string; the value of the second is a floating point number.
SPRpcValue *value;
value = sp_rpc_value_builder("{s:s,s:{s:s,s:d,s:(sss),s:d,s:b}}",
"object", "book", "description", "title",
"bla bla bla", "n_pages", (gdouble) 203,
"tags", "romantic", "horror",
"drammatic", "year", (gdouble) 2008,
"published", TRUE);
/* The JSON object should be:
{
"object" : "book",
"description" : {
"title" : "bla bla bla",
"n_pages" : 203.000000,
"tags" : [
"romantic",
"horror",
"drammatic"
],
"year" : 2008.000000,
"published" : true
}
} */
sp_rpc_value_unref(value);