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

Add floatingPointPrecision option in QJsonDocument

XMLWordPrintable

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

      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

        1. qjsonutils-1.cpp
          8 kB
        2. qjsonutils.cpp
          8 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:

                There are no open Gerrit changes