Using a function to translate incoming Velocity messages (MIDI) , to some widget parameters

I'm getting closer to my objective.

As per : Sending color to a button - #2 by jean-emmanuel

JS{{
var buttonState = OSC{/loop/0/01/rec};
var colors = {"cleared": "#222222", "play": "#00FF00", "rec": "#FF0000", "willPlay": "#004400", "willRec": "#440000"}

return colors[buttonState] || "auto"
}}

I can adapt this to do my own such as

JS{{
var velocityReceived = OSC{/note};
var colors = { 12: "#000000", 13: "#5f0000", 14: "#af0000" 15: "##ff0000" 29: "#ffdf00" 46: "#808000" 63: "#ffffaf" 28: "#005f0" 44: "#00af00" 60: "#00ff87" }

return colors[velocityReceived] || "#000000";
}}

And embedding that in the properties object on the .JSON file it would be

        "type": "button",
        "top": 40,
        "left": 10,
        "id": "1-1",
        "visible": true,
        "interaction": true,
        "width": 80,
        "height": 50,
        "expand": "false",
        "colorText": "auto",
        "colorWidget": "JS{{\n\nvar velocityReceived = OSC{/note};\nvar colors = { 12: "#000000", 13: "#5f0000", 14: "#af0000" 15: "##ff0000" 29: "#ffdf00" 46: "#808000" 63: "#ffffaf" 28: "#005f0" 44: "#00af00" 60: "#00ff87" }\nreturn colors[velocityReceived] || "#000000";\n\n}}",

But it is not working

Could not open file(SyntaxError: Unexpected token # in JSON at position 1105)

Quite strange cause line 1105 I got

        "colorStroke": "auto",

I know the syntax may be not correct, but I don't understand the error message