Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. JSON.stringify problem
Forum Updated to NodeBB v4.3 + New Features

JSON.stringify problem

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 2 Posters 914 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yetanotherqtfan
    wrote on 31 Jan 2018, 07:10 last edited by yetanotherqtfan
    #1

    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:
    0_1517382485078_96562f06-6d8d-4978-afe6-3fd5869ac263-图片.png

    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!

    J 1 Reply Last reply 31 Jan 2018, 08:26
    0
    • Y yetanotherqtfan
      31 Jan 2018, 07:10

      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:
      0_1517382485078_96562f06-6d8d-4978-afe6-3fd5869ac263-图片.png

      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!

      J Offline
      J Offline
      JonB
      wrote on 31 Jan 2018, 08:26 last edited by JonB
      #2

      @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 that JSON.parse(JSON.stringify(obj)) should return an object that is the same JS object as you started with. So what does JSON.parse() return in your case?

      &quot; is the HTML entitization of the " character.

      1 Reply Last reply
      0

      1/2

      31 Jan 2018, 07:10

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved