#<NoMethodError: undefined method `encode' for OpenStruct:Class>
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
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.
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>
- Dominant language
- Ruby
- Stars
- 175
- Forks
- 35
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
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.
More from ruby/ostruct
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100