Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert JavaScript variable into JSON

I want to insert a js variable into json (to show a message on slack). I have tested this :

 "fields":[  
     {  
        "title": "Reported by:",
        "value": "'+ user + '",
        "short": "false"
     },

but it doesn't work and show me this :

Reported by:

'+ user +'

Thanks you !

like image 924
Hakim Avatar asked Dec 15 '25 02:12

Hakim


1 Answers

It looks to me like you should be doing something like:

"value": "'" + user + "'",

Before user was still part of the string expression.

like image 51
thatidiotguy Avatar answered Dec 16 '25 17:12

thatidiotguy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!