Rename property of an object inside array

Viewed 2272

This is my input JSON

{
"uuid":123,
"description": [
    {
        "car_name":"Toyota",
        "saleDate":"23 May 2017"
    }
  ]
}

Expected output:

{
"uuid":123,
"description": [
    {
        "name":"Toyota",
        "saleDate":"23 May 2017"
    }
  ]
}

Rule : .description[]|={name:.car_name,saleDate}

I am able to achieve the desired result with this rule. However, is there a way I can rename the 'car_name' property to 'name' and also not mention all the other properties ( in this case, 'saleDate') in the rule. I might end up having 50+ properties inside the object and I do not want to mention all of them in the rule.

There can be more than one object in the array.

5 Answers
Related