Utilities
renameKeys
Remap schema field names without silently losing collisions.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { RenameKeysPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [RenameKeysPipe, JsonPipe],
template: `{{ {"first_name":"Ana"} | renameKeys: {"first_name":"name"} | json }}`,
})
export class ExampleComponent {
}
Template
{{ {"first_name":"Ana"} | renameKeys: {"first_name":"name"} | json }}
Try it live.
The output below runs the packed library. Edit data, not code.
Use double quotes for text, or a number, array, object or null.
Ordered parameters: mapping. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = {
"first_name": "Ana"
} as const;
readonly parameter0 = {"first_name":"name"} as const;
{{ value | renameKeys: parameter0 | json }}
Rendered output
{
"name": "Ana"
}