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

Add floatingPointPrecision option in QJsonDocument

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.5
    • Core: Serialization
    • None

    Description

      When doing a QJsonDocument::toJson(), the floating point precision for double/float is set to QLocale::[FloatingPointShortest|https://codebrowser.dev/qt6/qtbase/src/corelib/text/qlocale.h.html#QLocale::FloatingPointShortest] in qjsonwriter.valueToJson. wich cause the json to be quite heavy for no particular reason.

      So maybe:

      int floatingPointPrecision() const; 
      void setFloatingPointPrecision(int precision) const; 

      can be added to QJsonDocument (with the default value being QLocale::[FloatingPointShortest|https://codebrowser.dev/qt6/qtbase/src/corelib/text/qlocale.h.html#QLocale::FloatingPointShortest] so that it does not affect existing code bases

      Attachments

        1. qjsonutils-1.cpp
          8 kB
        2. qjsonutils.cpp
          8 kB

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              romain.donze Romain Donzé
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes