title: Query and group correct towards data in a azure table storage and post it to an API in correct nested .json format
body: <p>I have a lot data stored in an azure table storage table (string datatype).</p>
  <p>I want to post only certain of these fields to an API every x minute in a .json format using an azure function with timer trigger. Everything is good but:</p>
  <p>The format of the json is currently <strong>including</strong> square brackets, which I'm trying to <strong>remove</strong> without any sucess:</p>
  <p>The most important is to remove the brackets, so maybe I can &quot;hardcode&quot; something to remove the brackets? I have used a lot of time to get it in correct &quot;grouping&quot; format. Can it be done in a much easier way?</p>
  <pre><code>{
     &quot;Test&quot;:[
        {
           &quot;name&quot;:&quot;Tom&quot;
        }
     ],
     &quot;Info&quot;:[
        {
           &quot;Weight&quot;:&quot;122&quot;,
           &quot;Age&quot;:&quot;22&quot;
        }
     ],
     &quot;License&quot;:[
        {
           &quot;number&quot;:&quot;2222312&quot;
        }
     ]
  }
  </code></pre>
  <p><strong>First</strong>:
  I'm querying the data in the azure table storage:</p>
  <pre><code>        public async Task Run(
          [TimerTrigger(&quot;0 */5 * * * *&quot;, RunOnStartup = true)] TimerInfo myTimer,
          [Table(&quot;TestTable&quot;, Connection = &quot;STORAGE-ConnectionString&quot;)] CloudTable TestTable,
         ICollector&lt;string&gt; events,
          ILogger log)
      {
          try
          {
              TableContinuationToken token = null;
              List&lt;PersonEntity&gt; Entities = new List&lt;PersonEntity&gt;();
              do
              {
                var query = new TableQuery&lt;PersonEntity&gt;().Where(TableQuery.GenerateFilterCondition(&quot;Status&quot;
               , QueryComparisons.Equal, &quot;NEW&quot;));
  
                  var result = await TestTable.ExecuteQuerySegmentedAsync(query, token);
                  
                  Entities.AddRange(result.Results);
                  token = result.ContinuationToken;
                 
              } while (token != null);
  </code></pre>
  <p><strong>Secondly</strong>: I'm trying to collect only certain of the fields in the Azure table with the following code.</p>
  <pre><code>                IEnumerable&lt;IGrouping&lt;string, PersonEntity&gt;&gt; groupedEntities = Entities.GroupBy(x =&gt; x.PartitionKey);
  
              foreach (IGrouping&lt;string, PersonEntity&gt; group in groupedEntities)
  
              {
                  PersonEntity baseEntity = group.First();
  
                  var personBooking = new PersonBookingModel
  
                  {
                  Test = group.Select(x =&gt; new PersonBookingRouteModel 
                      {
                      name=x.PersonName.ToString()
                      }).ToList(),
                   Info = group.Select(x =&gt; new PersonBookingGoodsModel
                   {
                       Weight= x.PersonWeight.ToString(),
                       Age = x.PersonAge.ToString()
                   }).ToList(),
                   License = group.Select(x =&gt; new PersonBookingDriverModel
                   {
                       number = x.LicenceNumber.ToString(),                             
                   }).ToList()
                  };
  </code></pre>
  <p><strong>Furthermore</strong>:</p>
  <pre><code>try
                          {
                              var payload = JsonConvert.SerializeObject(personBooking);
                              using (HttpContent content = new StringContent(payload, Encoding.UTF8, &quot;application/json&quot;))
                              {
                                  if (payload == &quot;&quot;)
                                  {
                                      log.LogWarning(&quot;No payload created sucessfully&quot;);
                                  }
                              else {
                                      log.LogWarning(payload); 
                                          }
                       
                             
                                  latestResponse = await httpClient.PostAsync(Environment.GetEnvironmentVariable(&quot;API-Endpoint&quot;), content).ConfigureAwait(false);
                                  if (latestResponse.IsSuccessStatusCode)
                                  {
                                      log.LogWarning(&quot;Response with endpoint&quot;);
                                  }
                                  string data = await latestResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
  </code></pre>
  <p><strong>Desired output without brackets need to be:</strong></p>
  <pre><code>{
     &quot;Test&quot;:
        {
           &quot;name&quot;:&quot;Tom&quot;
        }
     ,
     &quot;Info&quot;:
        {
           &quot;Weight&quot;:&quot;122&quot;,
           &quot;Age&quot;:&quot;22&quot;
        }
     ,
     &quot;License&quot;:
        {
           &quot;number&quot;:&quot;2222312&quot;
        }
     
  }
  </code></pre>