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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:27:14+00:00 2026-05-26T01:27:14+00:00

My question is the next: When i try parse a json params with ‘json’

  • 0

My question is the next:

When i try parse a json params with 'json' gem on RUBY ON RAILS 3 throw this error:

 Unexpected token at 

Example

I have this object in ruby:

Then I have this html code:

<script>
        $("#selected").live('click', function(){
            jQuery.ajax({url: '<%= deselect_all_checkboxes_path %>', data: {contacts: '<%= contacts.to_json %>'}});
        });
</script>

<input type="checkbox" id="selected" value="1" >

I try this code in Rails Console

JSON.parse(json_string.gsub(/&quot;/, "\"")) 

Works ok. However when i try this code:

JSON.parse(params[:contacts].gsub(/&quot;/, "\"")) 

There is a problem in the gsub method. In Rails Console works ok but when i am debugging throw the error message. The problem is with “;” character.

Which could be the error?

  • 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-26T01:27:15+00:00Added an answer on May 26, 2026 at 1:27 am

    Unescape the HTML first and then parse it as straight JSON:

    JSON.parse(CGI.unescapeHTML(params[:contacts]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This helpful idea from Andy Gaskell supports 50% of my next question: I'd like
This is a followup on the question: ASP.NET next/previous buttons to display single row
This is an extension / next step of this question I asked a few
This is a follow up to the question Nested stored procedures containing TRY CATCH
Sorry to ask this question, but it's now day 3 I try to solve
Now I can add single value or tubles to the pipeline, my next question
I'm new in Android development and I have the next question/problem. I'm playing around
I'm new in Android development and I have the next question/problem. I'm playing around
Please be patient with my question, as this may be a bit longer. If
This may seem like the worlds simplest python question... But I'm going to give

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.