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 7999463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:30:48+00:00 2026-06-04T15:30:48+00:00

I have a problem of JSON encoding on my rails application: h = {:status=>200,

  • 0

I have a problem of JSON encoding on my rails application:

h = {:status=>200, :promotions=>[{:id=>719788, :title=>"test"}]}

and result of

puts h.to_json

is

{"status":200,"promotions":{"{\"id\"=>719788, \"title\"=>\"test\"}":null}}

Which is not the expected result!

This is the correct result:

{"promotions":[{"title":"test","id":719788}],"status":200}

What could generate such error in JSON generation?

ruby -v
ruby 1.9.3p194 (2012-04-20) [x86_64-linux]
rails -v
Rails 3.1.4
gem list ==> json (1.6.6, 1.5.4)
  • 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-06-04T15:30:50+00:00Added an answer on June 4, 2026 at 3:30 pm

    Ok, this has nothing to do with a configuration of rails or ruby…
    One of the engineer added this into core_extensions for Array

    def to_hash # Recursively convert array to hash 
     inject({}) do |hash, (key, value)|
       value = value.to_hash if value.kind_of?(Array)
       hash.merge!({key => value})
     end
    end
    

    I guess I can delete this question tomorrow

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

Sidebar

Related Questions

I have a problem with parsing a JSON result. This is what I get
I have problem with encoding in jQueryUI Autocomplete. Server side application is PHP and
I have a problem using JSON and arrays. Here is my code: while($row =
I have a problem accessing JSON data. I'm new to JSON and jquery so
I have a problem with deserializing JSON data from an external REST service. Depending
I have a problem in binding JSON data to KENDO Pie Chart. I have
I Have two problem in this Case : I want to pass a JSON
I'm having a problem. I have the list of JSON objects in a separate
Help me please. I have problem with encoding response string after GET request: var
i have another problem this time, i'm fetching json codes that will be used

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.