Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! 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