# shellcheck shell=bash disable=SC3010,SC3060,SC3003
___x_cmd_jo_escape___(){
    ___="${___//$'\\'/\\\\}"
    ___="${___//\"/\\\"}"
    ___="${___//$'\n'/\\n}"
    ___="${___//$'\t'/\\t}"
    ___="${___//$'\v'/\\v}"
    ___="${___//$'\b'/\\b}"
    ___="${___//$'\r'/\\r}"
    ___="\"$___\""
}

___x_cmd_jo_escape(){
    case "$___" in
        true|false|null|\{*\}|\[*\]) ;;
        *)
            if [[ ! "$___" =~ ^[-+]?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?$ ]]; then
                ___x_cmd_jo_escape___
            fi
    esac
}

___x_cmd_jo_list(){
    local s=
    local ___
    while [ $# -gt 0 ]; do
        case "$1" in
            :*)                 ___="${1#:}"
                                ___x_cmd_jo_escape___
                                s="$s,
${___}
";;
            *)
                    ___="$1"
                    ___x_cmd_jo_escape
                    s="$s,
${___}
"
                ;;
        esac
        shift
    done
    printf "%s" "[${s#?}]"
}

# shellcheck disable=SC3010,SC3060

# jo dict abc="$abc"
___x_cmd_jo_dict(){
    printf "{\n"

    local ___key
    local ___first=0

    local ___arg

    local ___
    for ___arg in "$@"; do
        if [ "$___first" -eq 0 ]; then
            ___first=1
        else
            printf ',\n'
        fi

        ___=${___arg%%=*}
        if [ "$___" != "$___arg" ]; then
            ___x_cmd_jo_escape___
            ___key="$___"
            ___=${___arg#*=}

            ___x_cmd_jo_escape
            printf '%s\n:\n%s\n' "$___key" "$___"
            continue
        fi

        ___=${___arg%%\:*}
        if [ "$___" != "$___arg" ]; then
            ___x_cmd_jo_escape___
            ___key="$___"
            ___=${___arg#*\:}
            ___x_cmd_jo_escape___
            printf '%s\n:\n%s\n' "$___key" "$___"
            continue
        fi

        ___x_cmd_jo_escape___
        ___key="$___"
        eval "___=\"\$$___arg\""

        ___x_cmd_jo_escape
        printf '%s\n:\n%s\n' "$___key" "$___"
    done

    printf "}\n"
}

