I'm having an issue with converting a Ruby array to JSON, saving it to MySQL, and then loading it into KnockoutJS. The problem is that the array remains a JSON string and I can't iterate over it.
tags = `/usr/bin/svn ls #{svn_repo_url}`.split("/\n")
puts tags.inspect
["1.0.0", "1.0.1", "1.0.10", "1.0.11", "1.0.12", "1.0.13", "1.0.14", "1.0.15", "1.0.16", "1.0.2", "1.0.3", "1.0.4", "1.0.5", "1.0.6", "1.0.7", "1.0.8", "1.0.9"]
puts tags.to_json
["1.0.0","1.0.1","1.0.10","1.0.11","1.0.12","1.0.13","1.0.14","1.0.15","1.0.16","1.0.2","1.0.3","1.0.4","1.0.5","1.0.6","1.0.7","1.0.8","1.0.9"]
After saving to MySQL and loading into KnockoutJS, the data remains a string, preventing me from looping through it with a foreach loop.
I have attempted ko.mapping.toJS(myString)
and ko.toJSON(myString)
without success in converting it to an array or object that I can iterate over.
Where am I going wrong in this process?
Thank you
UPDATE: The issue was resolved using eval(myString)