• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Bug in JSON parsing.. ?

    Suggestions and feature requests
    2
    6
    2283
    Loading More Posts
    • 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.
    • absolutelyfreeweb
      absolutelyfreeweb last edited by

      For an add-on, I'm trying to use JSON.parse() and JSON.Stringify(). Here is my code:

      alert(jsonStr);
      var jsonData = JSON.parse(jsonStr);
      var str = JSON.stringify(jsonData);
      alert(str);
      

      elements existing in jsonSTr are missing in str.

      Here is jsonStr:

      {
      "favorite": {
      "name": "Test Page",
      "url": "www.test.com"
      },
      "folder": {
      "name": "A Category",
      "subfavorite": [{
      "name": "Another Page",
      "url": "www.test.com"
      }, {
      "name": "3rd Page",
      "url": "www.test.com"
      }]
      },
      "favorite": {
      "name": "4th Page",
      "url": "www.tomorrow.com"
      }
      }

      in str, the first favorite is completly missing !! opera 38

      Reply Quote 0
        1 Reply Last reply
      • absolutelyfreeweb
        absolutelyfreeweb last edited by

        bug reported it at chromium:

        https://bugs.chromium.org/p/chromium/issues/detail?id=626949

        Reply Quote 0
          1 Reply Last reply
        • leocg
          leocg Moderator Volunteer last edited by

          What is your suggestion?

          Reply Quote 0
            1 Reply Last reply
          • absolutelyfreeweb
            absolutelyfreeweb last edited by

            It should either

            • throw a parse error if the syntax is not valid

            or if it is valid, not silently omit nodes but

            • return back all nodes in correct order.
            Reply Quote 0
              1 Reply Last reply
            • absolutelyfreeweb
              absolutelyfreeweb last edited by

              I have not looked it up in the RFCs but I think the second one is the correct way ( i.e. the syntax is valid ). A "duplicate key" is more like a limitation of the implementation and would not help me.

              Reply Quote 0
                1 Reply Last reply
              • leocg
                leocg Moderator Volunteer last edited by

                This forum is for suggestions. Since this topic doesn't seem to be a suggestion but a bug report, let's close it.

                If you want to report a bug, please do it in the appropriate section.

                Reply Quote 0
                  1 Reply Last reply
                • First post
                  Last post

                Computer browsers

                • Opera for Windows
                • Opera for Mac
                • Opera for Linux
                • Opera beta version
                • Opera USB

                Mobile browsers

                • Opera for Android
                • Opera Mini
                • Opera Touch
                • Opera for basic phones

                • Add-ons
                • Opera account
                • Wallpapers
                • Opera Ads

                • Help & support
                • Opera blogs
                • Opera forums
                • Dev.Opera

                • Security
                • Privacy
                • Cookies Policy
                • EULA
                • Terms of Service

                • About Opera
                • Press info
                • Jobs
                • Investors
                • Become a partner
                • Contact us

                Follow Opera

                • Opera - Facebook
                • Opera - Twitter
                • Opera - YouTube
                • Opera - LinkedIn
                • Opera - Instagram

                © Opera Software 1995-