Skip to content

#<NoMethodError: undefined method `encode' for OpenStruct:Class> #60

Description

@prateeksen

I am getting the below error when trying to parse a json object into class object.

#<NoMethodError: undefined method `encode' for OpenStruct:Class>

Code I am using:

# json_string = {"latitude":409146138,"longitude":124678384}
object = JSON.parse(json_string, object_class: OpenStruct)

Target Object looks like this:
<Routeguide::Point: latitude: 409146138, longitude: -746188906>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions