Unsolved JSON.stringify problem
-
I use QWebEngineView to load a simple webpage:
view = new QWebEngineView(this);
view->load(QUrl("file:///index1.html"));
The web page is:
<!doctype html>
<html>
<meta charset="utf-8">
<head>
</head>
<body><script>
var par={var1:"123","var2":456};
alert(JSON.stringify(par));
</script>
</body>
</html>The alert window is:
Note that all the quote marks in the object are encoded as html entities How could this happen? How to get the orignal " not html entities. The Qt version I use is Qt 5.10.0 MSVC2017 64 bit.
Thanks!
-
@yetanotherqtfan
Don't understand what your problem/issue/question is? That output is the JSON stringification of the object. All that stringify should gurantee is that the resulting string can be passed around safely, and thatJSON.parse(JSON.stringify(obj))
should return an object that is the same JS object as you started with. So what doesJSON.parse()
return in your case?"
is the HTML entitization of the"
character.