title: How can I return a C# Object instead of array JSON
body: <p>I have this code</p>
  <pre><code>return Ok(
  
  new object[]  
  {
  new { name = Dname, primaryLastName =DprimaryLastName, secondLastName= DsecondLastName,degrees= Ddegrees, roles= Droles, entityId = DentityId, enrollment = Denrollment, payrollNumber = DpayrollNumber, photo = Dphoto,  groupsInfo = rt , birthDate = DbirthDate} 
  }
  
  );
  </code></pre>
  <p>All variables values are string, except rt:</p>
  <pre><code>var rt = new Dictionary&lt;string, string&gt;();
  
  foreach (DataTable table in dsgroupsinfo.Tables)
  {
  foreach (DataRow dr in table.Rows)
  {
  rt.Add(&quot;required&quot;, dr[&quot;requerido&quot;].ToString());
  rt.Add(&quot;optional&quot;, dr[&quot;opcional&quot;].ToString());
  }
  }
  </code></pre>
  <p>My result from the service is this:</p>
  <pre><code>[
      {
          &quot;name&quot;: &quot;string&quot;,
          &quot;primaryLastName&quot;: &quot;string&quot;,
          &quot;secondLastName&quot;: &quot;string&quot;,
          &quot;degrees&quot;: &quot;string&quot;,
          &quot;roles&quot;: &quot;string&quot;,
          &quot;entityId&quot;: &quot;string&quot;,
          &quot;enrollment&quot;: &quot;string&quot;,
          &quot;payrollNumber&quot;: &quot;string&quot;,
          &quot;photo&quot;: &quot;string&quot;,
          &quot;groupsInfo&quot;: {
              &quot;required&quot;: &quot;string&quot;,
              &quot;optional&quot;: &quot;string&quot;
          },
          &quot;birthDate&quot;: &quot;string&quot;
      }
  ]
  </code></pre>
  <p>how can I get a response like this:</p>
  <pre><code>{
      &quot;name&quot;: &quot;string&quot;,
      &quot;primaryLastName&quot;: &quot;string&quot;,
      &quot;secondaryLastName&quot;: &quot;string&quot;,
      &quot;degrees&quot;: &quot;string&quot;,
      &quot;roles&quot;: &quot;string&quot;,
      &quot;entityId&quot;: &quot;string&quot;,
      &quot;enrollment&quot;: &quot;string&quot;,
      &quot;photo&quot;: &quot;&quot;,
      &quot;groupsInfo&quot;: {
          &quot;required&quot;:[&quot;string&quot;],
          &quot;optional&quot;: [&quot;string&quot;]
      }
  }
  </code></pre>
  <p>Please note there is no square brackets in the begining and the end, and inside groups info there are square brackets.</p>
  <p>Hope you can help me, thanks.</p>