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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:19:54+00:00 2026-06-10T04:19:54+00:00

JSON.parse(‘abc’.to_json) gives this error (in rails): JSON::ParserError: 757: unexpected token at ‘abc’ from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/json-1.7.4/lib/json/common.rb:155:in

  • 0
    JSON.parse('abc'.to_json) gives this error (in rails):

    JSON::ParserError: 757: unexpected token at '"abc"'
    from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/json-1.7.4/lib/json/common.rb:155:in `parse'
    from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/json-1.7.4/lib/json/common.rb:155:in `parse'
    from (irb):20
    from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
    from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
    from /Users/mpapper/.rvm/gems/ruby-1.9.2-p290@dfc-site/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:41:in `require'
    from script/rails:41:in `<main>'

Likewise this fails:

 JSON.parse(100.to_json)

And this too (with a slightly different error):

 JSON.parse(1.to_json)

Why dont I just wrap the outputted json in {} to make it look like real json?
Because I’m writing code that should be able to take any object and serialize it as JSON and pull it back out again.

I think the issue comes from this: JSON looks like a set of encoded key-value pairs all put within {}. But the to_json methods in rails (3.x) don’t output any {} at all.

Given that, all I really want is an easy way to serialize arbitrary ruby/rails objects into strings and back again. Already, many objects have a to_json method (String, Fixnum, Array, Hash) but the String and Fixnum versions don’t produce Json that can be parsed.

  • 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-10T04:19:56+00:00Added an answer on June 10, 2026 at 4:19 am

    It’s not the JSON you’re looking for. Try this:

    ActiveSupport::JSON.decode('abc'.to_json)
    ActiveSupport::JSON.decode(1.to_json)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error: JSON.parse: unexpected character when I run this statement in firebug:
Receiving this error (JSON.parse: unexpected character) when I try to parse a JSON validated
When parsing json using jQuery.parseJSON(), I get this error SyntaxError: JSON.parse: bad control character
I am trying to parse the JSON response from Wordnik's API. This is built
Using this to load the json var jsonParsed = JSON.parse(localStorage.getItem('test')); Using this to save
See this code: var jsonString = '{id:714341252076979033,type:FUZZY}'; var jsonParsed = JSON.parse(jsonString); console.log(jsonString, jsonParsed); When
Can not parse json using this var res = eval('(' + response + ')');
I am using JSON.parse to parse this JSON string [{created_at:2012-01-24T22:36:21Z,name:joe,age:42,updated_at:2012-01-24T22:36:21Z}] However I am simply
I'm trying to parse the json grabbed from here . Basically what I do
I want to parse json retrieved from url in jsp. My url is giving

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.