openwrt/libubox

libubox: add convenience function for adding anonymous strings to array container

pprindeville opened this issue · 2 comments

It's handy to have unnamed strings in array containers, such as network.lan.ports[] in /etc/board.json.

Please add a convenience function to support this, such as:

json_add_anon_string() {
        local cur
        _json_get_var cur JSON_CUR
        _json_add_generic string "" "$1" "$cur"
}

Not sure if it's worth adding a check to see if the cursor is currently in an array or not.

Hmm. Also a method for converting a JSON_CUR value into a path would be handy.

Partially addressed in PR #6