ruby - undefined method 'each_pair' with openstruct -


I'm using OpenStruct to manipulate Jason like this: OpenStruct.new '{" age ": 100," name ":" name "} '' and I'm getting

NoMethodError:" {\ "age \": 100, \ "name \" The undefined method for 'each_pair' "": \ "name \" ": string

This piece of code was working some time ago, and now it is not.

I am using Ruby 2.1

Just do this:

  requires 'json' OpenStruct.new (JSON.parse (your_string))   

will replace your JSON string object in Ruby hash object.

Comments

Popular posts from this blog

jsp - No mapping found for HTTP request with URI with annotation config Spring MVC and Jetty -

c# - Split String between 2 substrings without removing delimiters -

asp.net - Procedure or function "Procedure name" expects a parameter "Param name" which was not supplied occurs rarely -