Get Collection Column Names

Input collection: myTrucks5

YearMake ModelMileage
2020FordF15012343
2018ChevySilverado170567
2020FordF15098765
2017NissanFrontier123975
2016GMYukon98753


Output collection: mySolution5

Result
Make
Mileage
Model
Year


Solution code:

//Create a collection
ClearCollect(myTrucks5,
     {Year: 2020, Make: "Ford", Model: "F150", Mileage: 12343},
     {Year: 2018, Make: "Chevy", Model: "Silverado", Mileage: 170567},
     {Year: 2020, Make: "Ford", Model: "F150", Mileage: 98765},
     {Year: 2017, Make: "Nissan", Model: "Frontier", Mileage: 123975},
     {Year: 2016, Make: "GM", Model: "Yukon", Mileage: 98753}
 );

// Get column names
 Set(
     myJSON,
     Distinct(
         Ungroup(
             MatchAll(
                 JSON(
                     myTrucks2,
                     JSONFormat.IgnoreBinaryData
                 ),
                 "([^""]+?)""\s*:"
             ).SubMatches,
             "SubMatches"
         ),
         Value
     )
 )