How to escape double quote in JSON string
Topics related to client-side programming language.
Post questions and answers about JavaScript, Ajax, or jQuery codes and scripts.
-
Marius
- Posts: 106
How to escape double quote in JSON string
I am trying to parse a JSON string 'Hello " test' containing double quote which already escaped.
Code: Select all
JSON.parse('{"x":"Hello \" test "}')
But I get error:
Code: Select all
Uncaught SyntaxError: Unespected Tocken t in JSON
Is there anything I missed here?
MarPlo
You just need to escape the backslash \, so it turns into two backslashes \\
Code: Select all
let obj = JSON.parse('{"x":"Hello \\" test"}')
console.log(obj)
Similar Topics
-
SSEP - double search results, copy of current page as search result
Scripts from this website
First post
Hi there,
first of all I'd like to say thank you for this nice script.
I have implemented your script into my website:
haushalts-geld.de
and...
Last post
Thank you. And you do all that in your free time, amazing. You're awesome.
-
Get the length of a JSON object in JS
JavaScript - jQuery - Ajax
First post
I have converted a database table into a JSON object.
This is in essence a two-dimensional array, with each record being the first dimension, which...
Last post
You can use Object.keys to get the list of keys in the Object as an array and then get the length from it:
Object.keys(act_obj_array).length;
-
Foreach JSON RESPONSE from Api
PHP - MySQL
First post
Hello, i have a JSON response from an api that is like this: mluci.com/script.php
I tried to transform this to an array but i can't foreach this.For...
Last post
I resolved with this thank you:
I changed the code but this send only an api request :
<?php
$servername = localhost ;
$username = mluci_api ;...
-
Ajax-PHP Rating Stars-SyntaxError JSON.parse unexpected character
Scripts from this website
First post
The Ajax-PHP Rating Stars Script , I am trying to get it working but I keep getting this error:
SyntaxError: JSON.parse: unexpected character at...
Last post
Awesome, Finally I get it works, after adding this line alert(obajx.responseText); it guided me to what was missing, first of all, the files URL's...
-
Remove backslash from string
PHP - MySQL
First post
How can I remove backslashes from string in php?
I tried the following code.
$str ='abc-\123';
$str = stripcslashes($str);
echo $str; //...
Last post
You can use str_ireplace() to remove backslash from string in php, but like in the following code (add two backslashes into the removing argument):...