title: How to check if JSON object parameter exists?
body: <p>I have a ListModel of objects which may or may not have a <code>myvis</code> parameter (used for visibility). The ListView delegate should be visible if <code>myvis === true</code>. If <code>myvis</code> was not defined, I want to assume that <code>myvis === true</code></p>
  
  <p>For checking if <code>myvis</code> was defined and/or exists, I've tried 3 approaches:</p>
  
  <ul>
  <li><code>return (typeof myvis) === 'undefined' ? true : myvis</code></li>
  <li><code>return myvis === null ? true : myvis</code></li>
  <li><code>return hasOwnProperty("myvis") ? myvis : true</code></li>
  </ul>
  
  <p>None of which have been successful; see code output below </p>
  
  <pre><code>import QtQuick 2.9
  import QtQuick.Window 2.2
  
  Window {
      visible: true
      width: 640
      height: 480
  
      ListModel {
          id: myjson
          ListElement {
              displayName: "Planes"
              myvis: false
          }
          ListElement {
              displayName: "Trains"
              myvis: true
          }
          ListElement {
              displayName: "Automobiles"
          }
      }
  
  
      ListView {
          model: myjson
          anchors.fill: parent
  
          delegate: Text {
              text: displayName
              visible: {
                  console.log("typeof " + displayName + ":myvis is " + (typeof myvis))
                  console.log("hasOwnProperty " + hasOwnProperty("myvis"))
                  console.log(displayName + " is " + myvis)
  
                  //if myvis is not defined, assume it to be TRUE
                  return (hasOwnProperty("myvis") ? myvis : true)
              }
          }
      }
  }
  </code></pre>
  
  <p>Output I'm getting:</p>
  
  <pre><code>qml: typeof Planes:myvis is boolean
  qml: hasOwnProperty false
  qml: Planes is false
  qml: typeof Trains:myvis is boolean
  qml: hasOwnProperty false
  qml: Trains is true
  qml: typeof Automobiles:myvis is boolean
  qml: hasOwnProperty false
  qml: Automobiles is false
  </code></pre>
  
  <p>Output I'd expect:</p>
  
  <pre><code>qml: typeof Planes:myvis is boolean
  qml: hasOwnProperty true
  qml: Planes is false
  qml: typeof Trains:myvis is boolean
  qml: hasOwnProperty true
  qml: Trains is true
  qml: typeof Automobiles:myvis is undefined
  qml: hasOwnProperty false
  qml: Automobiles is undefined
  </code></pre>
  
  <p><strong>EDIT</strong>
  If the model is a JSON object and non-QML then it works:</p>
  
  <pre><code>    property var myjson: [
          {
              displayName: "planes",
              myvis: false
          },
          {
              displayName: "trains",
              myvis: true
          },
          {
              displayName: "automobiles"
          }
      ]
  
      ListView {
          model: myjson
          anchors.fill: parent
  
          delegate: Text {
              text: modelData.displayName
              visible: {
                  console.log("typeof " + modelData.displayName + ":myvis is " + (typeof modelData.myvis))
                  console.log("hasOwnProperty " + modelData.hasOwnProperty("myvis"))
                  console.log(modelData.displayName + " is " + modelData.myvis)
  
                  //if myvis is not defined, assume it to be TRUE
                  return (modelData.hasOwnProperty("myvis") ? modelData.myvis : true)
              }
          }
      }
  </code></pre>
  
  <p>Output is exactly as expected. Is there a way to get this output while retaining the ListModel and ListElements?</p>