mirror of https://github.com/mpv-player/mpv
misc/json: don't wrap top-level pretty strings/infs in quotes
This makes pretty-printing nodes substantially more friendly.
This commit is contained in:
parent
91ba71b09f
commit
fa7202d9f2
|
@ -300,12 +300,15 @@ static int json_append(bstr *b, const struct mpv_node *src, int indent)
|
||||||
bstr_xappend_asprintf(NULL, b, "%"PRId64, src->u.int64);
|
bstr_xappend_asprintf(NULL, b, "%"PRId64, src->u.int64);
|
||||||
return 0;
|
return 0;
|
||||||
case MPV_FORMAT_DOUBLE: {
|
case MPV_FORMAT_DOUBLE: {
|
||||||
const char *px = isfinite(src->u.double_) ? "" : "\"";
|
const char *px = (isfinite(src->u.double_) || indent == 0) ? "" : "\"";
|
||||||
bstr_xappend_asprintf(NULL, b, "%s%f%s", px, src->u.double_, px);
|
bstr_xappend_asprintf(NULL, b, "%s%f%s", px, src->u.double_, px);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case MPV_FORMAT_STRING:
|
case MPV_FORMAT_STRING:
|
||||||
write_json_str(b, src->u.string);
|
if (indent == 0)
|
||||||
|
APPEND(b, src->u.string);
|
||||||
|
else
|
||||||
|
write_json_str(b, src->u.string);
|
||||||
return 0;
|
return 0;
|
||||||
case MPV_FORMAT_NODE_ARRAY:
|
case MPV_FORMAT_NODE_ARRAY:
|
||||||
case MPV_FORMAT_NODE_MAP: {
|
case MPV_FORMAT_NODE_MAP: {
|
||||||
|
|
Loading…
Reference in New Issue