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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:53:52+00:00 2026-06-06T23:53:52+00:00

I have a JSON string I’ve parsed from a webpage, and I’m attempting to

  • 0

I have a JSON string I’ve parsed from a webpage, and I’m attempting to use json.loads() to turn it into a Python dictionary. However, some of the values in the JSON string contain double quotes, for example

'{"title": "The "Star Wars Kid": Where is he now?"}'

Obviously this is not a proper JSON string, and json.loads() complains. Using something like string.replace('"', '\\"') doesn’t work either, since this is a single string, and doing so would affect the double quotes that are correct as well as the bad ones.

By the way, this does not cause an HtmlXPathSelector error when scraping because on the webpage, the bad quotes are encoded like so

'{"title": "The "Star Wars Kid": Where is he now?"}'

How can I parse this string correctly with json.loads()?

EDIT: I understand that it would be simple to parse the string before the encoded quotes have been decoded (as in the second example), so I guess what I’m really asking is how to get this type of still-encoded result from a python HtmlXPathSelector.

If the HTML document I’m scraping contains this string

'{"title": "The "Star Wars Kid": Where Is He Now?"}'

How can I get HtmlXPathSelector to return that exact string without decoding the encoded quotation marks?

  • 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-06T23:53:53+00:00Added an answer on June 6, 2026 at 11:53 pm
    {"title": "The "Star Wars Kid": Where is he now?"}
    

    Here is when you want to decode the JSON. Then replace the “bad quotes” later.

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

Sidebar

Related Questions

Hi I have a json string converted unsing the JSON framework into a dictionary
I have a returned JSON string which I have parsed and put through into
I have json string from here: http://vkontakte.ru/al_video.php?act=load_videos_silent&al=1&oid=8046830 I use Touch json parser. //received json
I have a json string saved in my db. When i retrieve it from
I have a json string like this: http://pastebin.com/ckUZadwL I'm trying to use gson to
I have a JSON string called EmployeeList being passed back to my webpage. It
I have a JSON string such as below. That comes from a Website (the
I have this JSon string received from an AJAX call: {status:OK,addresses:[0,1,2,3,4,5]} To convert it
I have an JSON string that gets returned from the server that i'm trying
I have a JSON string(?) that I have returned from $.ajax() and named it

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.