I need to convert this string into an hash
{lhs: "1 Euro",rhs: "0.809656799 British pounds",error: "",icc: true}
I tried in this way
JSON.parse('{lhs: "1 Euro",rhs: "0.809656799 British pounds",error: "",icc: true}'.to_s)
JSON::ParserError: 757: unexpected token at '{lhs: "1 Euro",rhs: "0.809656799 British pounds",error: "",icc: true}'
any hint?
Your string is not a valid JSON transport. All keys must be quoted.
For example, this works:
If you cannot convert your hash string into a valid JSON transport, this should do the trick:
Using the regex:
/(?<key>\w+)\:/, which captures the key, then usinggsubto add quotes.