Prashant Ravi Darshan Prashant Ravi Darshan - 2 months ago 12
Ruby Question

Extract array in string rails

My string is

"[1,2,3]"


I want to get output in the below format

[1,2,3]


I want to extract array present in my string.

Answer

Just parse it with JSON.parse method like this ;

JSON.parse("[1,2,3]")