Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-29490

QML/JS formatting should not format paramétrable object key

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 11.0.1
    • Quick / QML Support
    • None
    • All

    Description

      in JavaScript, it is possible to create object simply with "{ }". the format of object is similar to a map 

      property var obj: {
         "key1": value1",
         "key2": value2"
      }
      console.log(JSON.stringify(obj))

      But sometime, you need not only the value to be a variable but also the key. It's possible to do it with [...] directly in the object

      property string key1: "property_name_1"
      property string key2: "property_name_2"
      property var obj: {
          [key1]: value1",
          [key2]: value2"
      } 
      console.log(JSON.stringify(obj))

      But when you format the file, the [ ... ] will be replace by " ... " giving the wrong key

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            dalverny Sébastien Dalverny
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes