bashsupport-pro
bashsupport-pro copied to clipboard
Embedded JSON Syntax Highlighting breaks for integer variable values
The following code reports an error in the syntax when it probably shouldn't:
var1="I Am A String"
var2=1402
var3="I Am Also A string"
DoAThing "MyArg" <<EOF # language=JSON
{
"my_string": "${var1}",
"my_number": ${var2},
"my_other_string": "${var3}"
}
EOF
Errors: ':' expected, got '}' and '<value> expected, got ',''

Version: 3.0.1.222
Thanks! I think this is an error of the embedded JSON parser, because the piece ${var2} is Bash code and excluded from the JSON and thus it appears like a missing value to the injected JSON. I'll check if/how this could be fixed...
Maybe instead of total exclusion you replace with "null" for the JSON parser? I don't think that covers all cases, but it should cover a lot of them.
Alternatively, depending on when the code is sent to the parser you might be able to sub in the real value if you have it.