-1

I'm passing the complete object in the value attribute of a radio button and that radio button is present in a data-table itself. I want all the columns data of that particular row in a data-table.

But the problem is some of their td contains some html structure and I only want their text value. So I tried to make a object of all the column (working on jinja template )and passing that object in the radio button itself.

{% set table_data ={'fileName':file_name,'fileType':file_type,'size':size,'createdBy':create_by,'lastModifiedDate':last_modified_date} -%}

<input type="radio" value={{data_table}}>

I got the value in the console

let obj=e.target.value;
  console.log(obj); // "{'fileName': 'This is the file2.png','fileType': 'file','size': '4.5 MB','createdBy': 'Anuj','lastModifiedDate': '23 Apr 2022, 06:00 PM'}"

but when I try to extract each value it is giving undefined in the console. How to solve this issue pls reply

Christopher
  • 3,124
  • 2
  • 12
  • 29
  • Does this answer your question? [How to parse JSON easily?](https://stackoverflow.com/questions/7301615/how-to-parse-json-easily) – gre_gor Jun 06 '22 at 18:24

1 Answers1

0

Looks like you have a stringified object. You'll need to parse it first:

let obj = JSON.parse(e.target.value);

console.log(obj);
Richie Bendall
  • 7,738
  • 4
  • 38
  • 58