Hello,
I’m new to shortcuts (but a mediom experienced programmer c/c++ javascript). Please be patient if I ask stupid questions.
I have a array of records (dictionaries) form an database query (text items and a random id)
[
{"id":131,"text":"Text 1"},
{"id":192,"text":"Text 2"},
{"id":123,"text":"Text 3"}
]
No I like the user choose a text using Choose from List
and process further with the id (not the text)
if my input to ’ Choose from List` looks like this it works as expected
{
"Text 1":131,
"Text 2":192,
"Text 3":123
}
But how to convert the array into the dictionary?
I repeat with each item in the array
to get all dictionaries in from the array
I’m stuck in setting a key in an dictionary by a variable using Set Dictionary Value
It seems that it does not support new keys - please correct me if I’m wrong
Do anybody can help me here? How can I populate a dictionary with (new) keys defined by variables.
Every help appreciated.
Chris
PS: For people who a familiar with JavaScript the solution would look like this (perhaps this clarifies my problem)
var result = {};
var input = [
{"id":131,"text":"Text 1"},
{"id":192,"text":"Text 2"},
{"id":123,"text":"Text 3"}
]
for (let item of input) {
result[item.text] = item.id;
}
console.log(result);