Dynamic creation of object from string
I have the string {"person":"me" ,"age":"30"}
embedded in a text. I extract it from the text using
text.match(/{.*}/);
I want to be able to use the object.keys
and object.values
methods to get keys to create menus dynamically and return the values based on menu selection.
It appears that I need to be able to create an object dynamically. I would like to do it without having to loop through the string. Is there any function or method that can take the result of text.match as input and give me json that can be used with object.keys
and object.values
etc.