I am converting a Ruby array to JSON, saving to MySQL and then loading into KnockoutJS. The problem is that the array stays a JSON string and I am unable to 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"]
This gets saved to MySQL and then gets loaded into KnockoutJS, but it stays as a string, so I am unable to iterate over it in a foreach loop.
I tried to do ko.mapping.toJS(myString)
and ko.toJSON(myString)
but so far having no luck and unable to convert to an an actual array or object I can iterate over
What am i doing wrong here?
Thank you
UPDATE: Solved with eval(myString)