Paragraph to Json conversation


I am try to convert the below sentence to some thing like this…

This : -

data": "2 Today 4 yesterday 28 Current-Week 2 Actionable-Tickets-Today 4 Actionable-Tickets-yesterday 24 Actionable-Tickets-Current-week 0 Non-Actionable-Tickets-Today 0 Non-Actionable-Tickets- yesterday 4 Non-Actionable-Tickets-Current- week"

To This: -

"Today": "2",
and so one

I tried some basic java scripting, but its not helping me. I would like to know, how can i achive this and if there are any samples please share it with me so that i can try.


Are you sure that data is correct?

Also, not a good question for this forum, it’s generic JS programming.

Anyway, split by space and go thru it with a for loop, like this

for(const i=0;i<dataArr.length;i+=2){