[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] pactl: fix invalid JSON output by overriding LC_NUMERIC
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Mon May 16 18:18:03 UTC 2022
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
c3c84a36 by Olivier Gayot at 2022-05-16T18:15:47+00:00
pactl: fix invalid JSON output by overriding LC_NUMERIC
When the --format json parameter is given on the command line, we
attempt to produce a JSON output for most commands.
Our implementation of the JSON serialization uses vsnprintf to output
numbers. Unfortunately, vsnprintf is affected by the locale and more
specifically the LC_NUMERIC variable.
When LC_NUMERIC is set to, for instance, fr_FR.UTF-8, floating-point
numbers are output with a comma as the decimal separator, which is then
considered invalid JSON.
$ LC_NUMERIC=fr_FR.UTF-8 pactl --format json list sinks | jq .
parse error: Objects must consist of key:value pairs at line 1, column 435
This is the token which failed to parse:
}},"balance":0,00,"base_volume":{
Fixed by overriding the LC_NUMERIC value when we request JSON output.
Signed-off-by: Olivier Gayot <olivier.gayot at sigexec.com>
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/702>
- - - - -
1 changed file:
- src/utils/pactl.c
Changes:
=====================================
src/utils/pactl.c
=====================================
@@ -2746,6 +2746,7 @@ int main(int argc, char *argv[]) {
format = TEXT;
} else if (pa_streq(opt_format, "json")) {
format = JSON;
+ setlocale(LC_NUMERIC, "C");
} else {
pa_log(_("Invalid format value '%s'"), opt_format);
goto quit;
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/c3c84a3691e700157ccd3c75fdae53c6eec89775
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20220516/f14214ec/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list