0

I've got objects thats stores some data in hstore (filters), and that filters also have an arrays inside.

How to transform this arrays in string class to normal arrays?

OpenStruct.new(@object.filters)
=> #<OpenStruct name="sth", email="sth", phone="123", subject="[\"\", \subject1\", \"subject2\", \"subject3\"]">

1 Answer 1

2

Use JSON or YAML parsers.

require 'json'

obj = OpenStruck.new(@object.filters)
JSON.parse obj.subject

Or,

require 'yaml'

obj = OpenStruck.new(@object.filters)
YAML.load obj.subject
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.