Method: #parse_data
- Defined in:
- lib/ugc/helpers/parse.rb
#parse_data(input) ⇒ Object
returns a json string
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ugc/helpers/parse.rb', line 31 def parse_data(input) return unless input # must be wrapped in {} input = "{#{input}}" unless input.start_with? '{' or input.start_with? '[' # must be a json string or 1.9 hash format begin MultiJson.dump(eval(input)) rescue SyntaxError input end end |