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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:24:30+00:00 2026-05-23T13:24:30+00:00

By definition the JSON string is wrapped with double quote. In fact: json.loads(‘{v:1}’) #works

  • 0

By definition the JSON string is wrapped with double quote.

In fact:

json.loads('{"v":1}') #works

json.loads("{'v':1}") #doesn't work

But how to deal with the second statements?
I’m looking for a solution different from eval or replace.
Thanks.

  • 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-23T13:24:31+00:00Added an answer on May 23, 2026 at 1:24 pm

    Not sure if I got your requirements right, but are you looking for something like this?

    def fix_json(string_):
        if string_[0] == string_[-1] == "'":
            return '"' + string_[1:-1] +'"'
        return string_
    

    Example usage:

    >>> fix_json("'{'key':'val\"'...cd'}'")
    "{'key':'val"'...cd'}"
    

    EDIT: it seems that the humour I tried to have in making the example above is not self-explanatory. So, here’s another example:

    >>> fix_json("'This string has - I'm sure -  single quotes delimiters.'")
    "This string has - I'm sure -  single quotes delimiters."
    

    This examples show how the “replacement” only happens at the extremities of the string, not within it.

    you could also achieve the same with a regular expression, of course, but if you are just checking the starting and finishing char of a string, I find using regular string indexes more readable….

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

Sidebar

Related Questions

I have a serialized JSON String (chef role definition actually) and it has a
Whats wrong in below JSON Object definition I am trying to create a new
Definition of variables in use: Guid fldProId = (Guid)ffdPro.GetProperty(FieldId); string fldProValue = (string)ffdPro.GetProperty(FieldValue); FormFieldDef
I have the following string from a REST JSON response: [ { uid:10512213, name:Bob
I get the Json from google. it has many details on many things but
I need to generate java class definition from json data. Is there any tool
The JSON syntax definition say that html/xml tags (like the <script>...</script> part) are not
So, I know the definition of json, I know its a lightweight data format.
I'm using jquery to send a json string to an ASMX web service. The
I'm trying to load JSON back into an object. The loads method seems to

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.