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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:42+00:00 2026-05-26T10:12:42+00:00

I noticed that if I put double quotes on my input boxes that get

  • 0

I noticed that if I put double quotes on my input boxes that get passed to php via json, json_decode will return null. Thus, I decided to replace double quotes with \" when making my json.

Thus, I have something like:

var valueToSet = input.replace(/"/gi, '\\"');

The code above replaces "" with \" … This works, and now I can input stuff like:

Hello hi "" " " " ' ' '' ' ' ' """ 

without breaking anything. However, if I input something like:

Hello hi "" \ "

it gets broken. How can I include to the above replace that slashes get also replaced? And what should I replace slashes with? with \\ ?

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-26T10:12:43+00:00Added an answer on May 26, 2026 at 10:12 am

    You should not worry about these issues. I think you’re buiding your JSON by hand, while you should use a dedicated function that will take care of those details for you.

    • YUI JavaScript library has a JSON object with a JSON.stringify method that will work in all browsers and will use the native implementation if present.
    • Newer browsers implement JSON.stringify (IE from version 8.0, Firefox from version 3.5, Chrome from version 4.0, Safari from version 4.0, Opera from version 10.5)
    • Douglas Crockford, has written a JSON library
    • On the server side, PHP has json_encode
    • There is support for any other server side language, see json.org for details

    To answer your last question, yes, \ should be replaced with \\, but again, it should be done by json_encode.

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

Sidebar

Related Questions

I noticed that you can call Queue.Synchronize to get a thread-safe queue object, but
I have noticed that some applications (BeejiveIM) that you can put the red badge
I have noticed that I have to put flv files in the same or
I have noticed that, from Google Maps page, you can get an embed link
I have noticed that cURL in PHP returns different data when told to output
Using Visual Studio 2010 I put a breakpoint on Application_AuthenticateRequest today and noticed that
I've noticed that google calendar doesn't allow me to put html into the body
I've noticed that some email services (like gmail or my school's webmail) will redirect
I've noticed that some web developers put IDs on scripts tags. For example: <script
I've just put some photos up online and I noticed that they photos appear

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.