bashsupport-pro icon indicating copy to clipboard operation
bashsupport-pro copied to clipboard

Embedded JSON Syntax Highlighting breaks for integer variable values

Open TheAks999 opened this issue 3 years ago • 2 comments

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 ','' image

Version: 3.0.1.222

TheAks999 avatar Nov 10 '22 16:11 TheAks999

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...

jansorg avatar Nov 10 '22 16:11 jansorg

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.

TheAks999 avatar Nov 10 '22 21:11 TheAks999