Spa Json
Similar to WpSpaPod
, this MR adds a new WpSpaJson
API to create and parse Json objects. A Lua API for WpSpaJson is also added.
See tests/wp/spa-json.c
and tests/wplua/scripts/json.lua
for its usage.
Merge request reports
Activity
requested review from @gkiagia
assigned to @gkiagia
added 6 commits
-
89f14477...0272e11c - 3 commits from branch
pipewire:master
- 4c157411 - spa-json: add new WpSpaJson API
- 20187e07 - m-lua-scripting: add WpSpaJson API
- 5bef0f24 - default-nodes: use WpSpaJson API
Toggle commit list-
89f14477...0272e11c - 3 commits from branch
Looks great! Two things that I have in mind as I am looking at the code:
- it would possibly be useful to have a from_string() constructor in lua
- could we figure out a way to use this in the lua config files as well? For example, we currently have things like:
["bluez5.auto-connect"] = "[ hfp_hf hsp_hs a2dp_sink ]",
. It would be nice if we could write it as["bluez5.auto-connect"] = { "hfp_hf", "hsp_hs", "a2dp_sink" },
and encode the array in json before passing it to WpProperties
- it would possibly be useful to have a from_string() constructor in lua
This is very easy to add in Lua as there is a
wp_spa_json_new_from_string ()
API in C.- could we figure out a way to use this in the lua config files as well? For example, we currently have things like:
["bluez5.auto-connect"] = "[ hfp_hf hsp_hs a2dp_sink ]",
. It would be nice if we could write it as["bluez5.auto-connect"] = { "hfp_hf", "hsp_hs", "a2dp_sink" },
and encode the array in json before passing it to WpProperties
You can do this now with just:
["bluez5.auto-connect"] = Json.Array { "hfp_hf", "hsp_hs", "a2dp_sink" } : get_data()
I am not sure if it is a good idea to automatically create a Json array implicitly with just:
["bluez5.auto-connect"] = { "hfp_hf", "hsp_hs", "a2dp_sink" }
Because maybe a user wants to just have a Lua table instead of a Json array.
Edited by Julian Bouzas