title: Minimal Example on how to read, write and print QJson code (with QJsonDocument, QJsonArray, QJsonObject, QFile)
body: <p>I am searching for a minimal full executable qt or c++ code example to parse and write this Json code:</p>
  
  <pre class="lang-Json prettyprint-override"><code>{
      "FirstName": "John",
      "LastName": "Doe",
      "MiddleName": null,
      "Age": 43,
  
      "Address": {
          "Street": "Downing Street 10",
          "City": "London",
          "Country": "Great Britain"
      },
      "Phone numbers": [
          "+44 1234567",
          "+44 2345678"
      ]
      "Valid":true,
  }
  </code></pre>
  
  <ul>
  <li>The above example consists of an object with 5 key/value pairs. Two of the values are strings, one is a number,</li>
  <li>one is another object and the last one an array.</li>
  <li>A valid JSON document is either an array or an object, so a document always starts with a square or curly bracket.</li>
  </ul>
  
  <p>EDIT:</p>
  
  <ul>
  <li>Json has <a href="https://www.w3schools.com/js/js_json_datatypes.asp" rel="nofollow noreferrer">2 more</a> key/value pairs - value 'null' and 'bool'</li>
  </ul>
  
  <p>And yes, I have seen a <a href="https://doc.qt.io/qt-5/qtcore-serialization-savegame-example.html" rel="nofollow noreferrer">"Save Game Example"</a>
  and tried to figure it out. </p>
  
  <p>But after nearly a week I gave up to transfer a minimal Example without enums, QVectors and 3 different header Files over to my project to handle the code snippet. Doesn't matter if its for a widget or core code.</p>
  
  <p>I already did a xml read and write program successfully but it seems I miss some Important point and get errors with json that may or may not have to do with the parsing. I am not able to rule it out without a minimal fully working code example.</p>
  
  <p>So my question is: <em>Could you please provide a minimal Example to write, read and print the Json file? Thanks upfront.</em></p>