m-lua-scripting: always parse JSON to String if its type is not recognized

This allows parsing JSON strings without quotes.
This commit is contained in:
Julian Bouzas
2023-08-11 14:48:13 -04:00
parent e24e52c6d3
commit 227dd97036
2 changed files with 15 additions and 7 deletions

View File

@@ -123,13 +123,6 @@ push_luajson (lua_State *L, WpSpaJson *json)
lua_pushnumber (L, value);
}
/* String */
else if (wp_spa_json_is_string (json)) {
g_autofree gchar *value = wp_spa_json_parse_string (json);
g_warn_if_fail (value);
lua_pushstring (L, value);
}
/* Array */
else if (wp_spa_json_is_array (json)) {
g_auto (GValue) item = G_VALUE_INIT;
@@ -163,6 +156,13 @@ push_luajson (lua_State *L, WpSpaJson *json)
lua_setfield (L, -2, key_str);
}
}
/* Otherwise alwyas parse as String to allow parsing strings without quotes */
else {
g_autofree gchar *value = wp_spa_json_parse_string (json);
g_warn_if_fail (value);
lua_pushstring (L, value);
}
}
static int