Community Tip - You can change your system assigned username to something more personal in your community settings. X
In standard javascript one would simply do this..
let key = "somthing"
let jsonObject = {[key]: "value"}
But Thingworx doesn't allow this. How can I set a key using a variable in thingworx?
Solved! Go to Solution.
let jsonObject= {}
userInput[key] = "value"
Hello,
The code you have given doesn't seem to include all of the information needed as "userInput" and "key" are undefined.
Here is a complete code showing how you can use a variable for the key value of a JSON:
let jsonObject = {};
let key = "myKey";
let value = "myValue";
jsonObject[key] = value;
Regards,
Jens