Problem 1: Can this be achieved in javascript?
value = "['iPhone', 'iBall']"
to
value = ['iPhone', 'iBall']
Problem 2: To make it harder, The values are encoded:
value = "['iPhone', 'iball']"
Does this help ?
var value = "['iPhone', 'iBall']";
value = JSON.parse(value.replaceAll(`'`, `"`));
console.log(value);
value = "['iPhone', 'iball']";
value = JSON.parse(value.replaceAll(`'`, `"`));
console.log(value);
console.log(typeof(value));
{'key': ['values']} Not working well. so added nested dict. {key: {key: ['values']}} worked. Even this approach got me an encoded response but after replacing it(above solution). it worked well.replaceAll() which will replace the occurrences of Apostrophe, both ( ' ), as well as encoded ('), with ` " `.value was object (array), and not string. I just didn't assigned the object to value variable, and generated console directly.
{{ value|safe }}instead of'{{ value }}'do not include double or single quotes