title: How to get total length of JSON object using ajax
body: <p>I have JSON in URL and I am showing the total length of JSON array, but not showing the length of an object. Please view the code and correct the code. </p>
  
  <pre><code>    $(document).ready(function () {
          $.ajax({
              url: "/hehe/GetAllBus",
              data: "",
              type: "GET",
              dataType: "json",
              success: function (dataBus1) {
                  loaddataBus(dataBus1);
              },
              error: function () {
                  alert("Failed! Please try again.");
              }
          });
      });
  
      function myFunction() {
          var fruits = dataBus1;
          document.getElementById("demo12").innerHTML = fruits.length;
      }
  </code></pre>
  
  <p>Print the length of array</p>
  
  <pre><code>&lt;code&gt;
     &lt;body onload="myFunction()"&gt;
         &lt;p id="demo12"&lt;/p&gt;
      &lt;/body&gt;
  &lt;/code&gt;
  </code></pre>