#<NoMethodError: undefined method `encode' for OpenStruct:Class>
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 175
- Forks
- 35
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
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>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the JSON.parse call with object_class: OpenStruct and read the OpenStruct implementation involved in the error. Compare the reported NoMethodError with the expected Routeguide::Point-style object; the issue is resolved when the cause and expected parsing behavior are established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100