Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-127035

QJson: Improve error messages

XMLWordPrintable

    • Icon: User Story User Story
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.7.0, 6.8
    • Core: Serialization
    • None
    • All
    • 13
    • Foundation PM Staging

      The human readable error messages that QJSon generates for incorrect JSON are not really guiding the user to see the problem. This becomes obvious when comparing it to the error messages e.g. JSON.parse in a web browser generates :

      Using {} instead of []

      Here the user mixed up array syntax and object syntax:

      { "hello", "world" }
      

      QJson error:

      missing name separator
      

      JavaScript error:

      JSON.parse: expected ':' after property name in object at line 1 column 10 of the JSON data
      

      Similarly, [ "Key": "Value" ] got missing value separator from QJson.

      Forgetting comma in object list

      {
          "hello": "world"
          "hi": "there"
      }
      

      QJson error

      unterminated object
      

      JavaScript error:

      JSON.parse: expected ',' or '}' after property value in object at line 3 column 5 of the JSON data
      

      Missing quotes

      { "hello": world }
      

      QJson error

      illegal number
      

      JavaScript error:

      JSON.parse: unexpected character at line 1 column 12 of the JSON data
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            cnn Qt Core & Network
            kkohne Kai Köhne
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes