mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
properties: support properties from json object sting
Make pw_properties_new_string() work with a json object string. This makes it possible to specify property strings as more complex objects and escape characters.
This commit is contained in:
parent
62cdec8448
commit
6e4c138238
3 changed files with 96 additions and 20 deletions
|
|
@ -310,6 +310,23 @@ static void test_parse(void)
|
|||
spa_assert(pw_properties_parse_double("1.234") == 1.234);
|
||||
}
|
||||
|
||||
static void test_new_json(void)
|
||||
{
|
||||
struct pw_properties *props;
|
||||
|
||||
props = pw_properties_new_string("{ \"foo\": \"bar\\n\\t\", \"bar\": 1.8, \"empty\": [ \"foo\", \"bar\" ], \"\": \"gg\"");
|
||||
spa_assert(props != NULL);
|
||||
spa_assert(props->flags == 0);
|
||||
spa_assert(props->dict.n_items == 4);
|
||||
|
||||
spa_assert(!strcmp(pw_properties_get(props, "foo"), "bar\n\t"));
|
||||
spa_assert(!strcmp(pw_properties_get(props, "bar"), "1.8"));
|
||||
fprintf(stderr, "'%s'\n", pw_properties_get(props, "empty"));
|
||||
spa_assert(!strcmp(pw_properties_get(props, "empty"), "[ \"foo\", \"bar\" ]"));
|
||||
|
||||
pw_properties_free(props);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
test_abi();
|
||||
|
|
@ -321,6 +338,7 @@ int main(int argc, char *argv[])
|
|||
test_new_string();
|
||||
test_update();
|
||||
test_parse();
|
||||
test_new_json();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue