Need to structure JSON Array inside the Array group by its fields

I have the following structure of CS,

Goal Class:

public int Id { get; set; }
public string GoalName { get; set; }
public string CompanyName { get; set; }
//Navigation
public ICollection<Criteria> Criteria { get; set; }

and Criteria Class:

public int Id { get; set; }    
public int Layer { get; set; }
public string CriteriaName { get; set; }
[ForeignKey(nameof(Goals))]
public int GoalId { get; set; } 
public Goals Goals{ get; set; }

And Repository Class is written as:

public Goals GetGoalsById(int goalsId)
        {
            return FindByCondition(g => g.Id.Equals(goalsId))
                .Include(crt=>crt.Criteria)..FirstOrDefault();;

API Structure is Look like:

{
  "goalName": "Today Goal ",
  "criteria": [
    {
      "layer": 1,
      "criteriaName": "Cat 1"
    },
    {
      "layer": 1,
      "criteriaName": "Cat 2"
    },
    {
      "layer": 1,
      "criteriaName": "Cat 3"
    },
    {
      "layer": 2,
      "criteriaName": "C3"
    },
    {
      "layer": 2,
      "criteriaName": "C4"
    },
    {
      "layer": 2,
      "criteriaName": "C5"
    }
  ],
}

But I want to JSON display group by layer like :

     "goalName": "Today Goal ",
  "criteria": [

    "layer 1": [        
    {
      
      "criteriaName": "Cat 1"
    },
    {
      
      "criteriaName": "Cat 2"
    },
    {
      
      "criteriaName": "Cat 3"
    }
],
"layer 2": [
    { 
      "criteriaName": "C3"
    },
    { 
      "criteriaName": "C4"
    },
    { 
      "criteriaName": "C5"
    }
  ],
}

What would I do to achieve this kind JSON structure? The Layer is a int type fields in the criteria table, I need to display data with group by the layer so can call all the layer related data in a pair.