Reputation: 3898
I have data like:
"[{\"workstationName\":\"Test Workstation Id 123\"},{\"workstationName\":\"Alex's Workstation\"}]"
I want it to simply be:
[{"workstationName":"Test Workstation Id 123"},{"workstationName":"Alex's Workstation"}]
I should know this. I tried a.to_ary
, but no good. Any straight-forward way to process this? Thanks.
Upvotes: 0
Views: 77
Reputation: 118271
How is this ?
require 'json'
require 'yaml'
JSON.parse("[{\"workstationName\":\"Test Workstation Id 123\"},{\"workstationName\":\"Alex's Workstation\"}]")
# => [{"workstationName"=>"Test Workstation Id 123"},
# {"workstationName"=>"Alex's Workstation"}]
YAML.load("[{\"workstationName\":\"Test Workstation Id 123\"},{\"workstationName\":\"Alex's Workstation\"}]")
# => [{"workstationName"=>"Test Workstation Id 123"},
# {"workstationName"=>"Alex's Workstation"}]
Upvotes: 3