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

Add convenient JSON API to modify documents

    XMLWordPrintable

Details

    Description

      The current API appears to make modifications to values instead of the
      document itself. This makes it quite cumbersome to modify a document.
      For example, to change the value of 5 to 10 in the json "[1, 2, [3, 4,
      [5, 6]]]", one has to write the following code.

      QJsonDocument doc = QJsonDocument::fromJson("[1, 2, [3, 4, [5, 6]]]");
      QJsonArray a1 = doc.array();
      QJsonArray a2 = a1[2].toArray();
      QJsonArray a3 = a2[2].toArray();

      a3[0] = 10;
      a2[2] = a3;
      a1[2] = a2;

      That is to change a value somewhere in the document, one has to update and then update all the way up.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            girish Girish Ramakrishnan
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            17 Vote for this issue
            Watchers:
            23 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes