xxxxxxxxxx
let data = [
{id: 1, country: 'Germany', population: 83623528},
{id: 2, country: 'Austria', population: 8975552},
{id: 3, country: 'Switzerland', population: 8616571}
];
let dictionary = Object.assign({}, data.map((x) => ({[x.id]: x.country})));
// {1: "Germany", 2: "Austria", 3: "Switzerland"}
xxxxxxxxxx
// Convert array string to dictionary, ex: ['choice_a', 'choice_b'] => {choice_a: true, choice_b: true }
const paramsChecked = Object.assign({}, listChecked.map((x) => ({[x]: true})))
xxxxxxxxxx
var createDict = R.pipe(R.pluck('id'), R.map(R.pair(R.__, 0)), R.fromPairs);
var places = [{ id: 'place1id' }, { id: 'place2id' }];
var placesDict = createDict(places);
// {"place1id": 0, "place2id": 0}