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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:36:07+00:00 2026-06-18T09:36:07+00:00

I try parsing a very simple json string I get from the net: {price

  • 0

I try parsing a very simple json string I get from the net: {“price” : ‘10.25’}
As you can see, the number (10.25) is between single quotes and it seems to be a problem for simple json:

Reproduction:

import simplejson as json
json_str = """ {"price" : '10.25'} """
json.loads(json_str)

Result:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.5/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/pymodules/python2.5/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/pymodules/python2.5/simplejson/decoder.py", line 353, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

However, if I change the single quotes to double ones – it works.\
Unfortunately, the jsons I get are not as simple as in the example above, so I can’t just replace all single quotes with string replace command.

Anybody knows what is the right way to parse this json?

P.S. I use python 2.5.

Thanks a lot!

  • 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-18T09:36:09+00:00Added an answer on June 18, 2026 at 9:36 am

    {"price" : "10.25"} , JSON contains double quotes only.

    The JSON with single quotes is invalid ( see : http://www.jsonlint.com ) :

    Parse error on line 2:
    {    "price": '10.25'}
    --------------^
    Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
    

    You can correct your json using regex replace, or use ast.literal eval to load it as python object ( or dump it as json and load it again )

    >>> a = """ {"price" : '10.25'} """
    >>> import ast
    >>> new_dict = ast.literal_eval(a.strip())
    >>> import json
    >>> json.dumps(new_dict)
    '{"price": "10.25"}'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing a JSON string: Response: {success:false,displaymessage:UserName or Email already exist. Please try
I have a simple Android app that reads some JSON data from a php
I try to send FINS commands through UDP from PC (C#.NET) to PLC Ethernet
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
I try to build a very simple calculator supporting x,y,+,-,*,/(,). The idea is simple:
Zend Framework 1 had a very simple way of parsing URL routes and setting
I'm trying to build a very simple Admin area where the administrator can approve
i try to parsing json with format like this { bossresponse:{ responsecode:200, web:{ start:0,
I have a very simple class CompiledFunction (MarshalByRefObject) - I try to create an

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.