Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:09:11+00:00 2026-05-18T03:09:11+00:00

It seems that with an object like this: #<Course id: 1, name: Targeting Triple

  • 0

It seems that with an object like this:

#<Course id: 1, name: "Targeting Triple Negative Breast Cancer", description: nil, disclosure: nil, created_at: "2010-11-11 14:43:31", updated_at: "2010-11-11 14:43:31", picture: nil, course_reference_id: nil, authors: "Lisa A. Carey, M.D.", volumn_number: nil, publication_date: nil, expiration_date: nil, credits: 1, featured: false>

I should be able to do JSON.parse(course.to_json), but when I try this, instead of returning the original object, I get the equivalent of Course.new (an object with nil attributes).

When I do course.to_json I get:

"{\"attributes\":{\"name\":\"Targeting Triple Negative Breast Cancer\",\"expiration_date\":null,\"created_at\":\"2010-11-11 14:43:31\",\"featured\":\"0\",\"publication_date\":null,\"updated_at\":\"2010-11-11 14:43:31\",\"id\":\"1\",\"disclosure\":null,\"volumn_number\":null,\"credits\":\"1\",\"authors\":\"Lisa A. Carey, M.D.\",\"course_reference_id\":null,\"description\":null,\"picture\":null},\"json_class\":\"Course\",\"attributes_cache\":{}}"

But when I do JSON.parse(course.to_json) I get:

#<Course id: nil, name: nil, description: nil, disclosure: nil, created_at: nil, updated_at: nil, picture: nil, course_reference_id: nil, authors: nil, volumn_number: nil, publication_date: nil, expiration_date: nil, credits: nil, featured: false>

I am using Rails 2.3.5 and I get the same result with other objects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:09:12+00:00Added an answer on May 18, 2026 at 3:09 am

    To serialize/deserialize the object use #to_json and #from_json. Don’t try to parse the JSON string directly.

    json = Course.new(...).to_json
    Course.new.from_json(json)
    

    Also note you should avoid calling JSON.parse directly. Use ActiveSupport::JSON bridge instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently learning Object oriented Javascript but it seems that the alert is
It seems that when a WPF application starts, nothing has focus. This is really
I just uncovered this confusion and would like a confirmation that it is what
I would like to use with on an object that uses __getattr__ to redirect
I have an object in C# like this: private ClassWidget { public int ID;
Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel):
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that in a standard Xcode project, the default target automatically updates the
It seems that using Critical Sections quite a bit in Vista/Windows Server 2008 leads
It seems that MSMQ doesn't use any Database management system to manage messages. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.