3

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 !

2 Answers 2

1

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

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

Before user was still part of the string expression.

Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work but thanks for your help. Here is the code is use : [ { "pretext": "", "text": "test", "color": "#F35A00", "fields": [ { "title": "Reported by :", "value": "'" + user + "'", "short": "false" }, { "title": "Project:", "value": "No", "short": "false" } ] } ]
1

This is called string concatenation:

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

The value will produce a string with the combined values, such as if user were a string value of "Jamen", the concatenated value of value would be "'Jamen'"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.