Utilities
pathEntries
Flatten own leaf values to key-array paths, without dotted-key ambiguity.
Use it in your component
Standalone component
import { Component } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { PathEntriesPipe } from 'extra-pipe';
@Component({
standalone: true,
imports: [PathEntriesPipe, JsonPipe],
template: `{{ data | pathEntries | json }}`,
})
export class ExampleComponent {
readonly data = { profile: { name: "Ana" } };
}
Template
{{ data | pathEntries | 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.
No parameters: use []. Locale is controlled separately.
This pipe has no locale override.
Live template data
readonly value = {
"profile": {
"name": "Ana"
}
} as const;
{{ value | pathEntries | json }}
Rendered output
[
{
"path": [
"profile",
"name"
],
"value": "Ana"
}
]