Angular check if object is empty in template

Solution which works with empty object, null and undefined as a value:

<ng-container *ngIf="(user | keyvalue)?.length">
    {{ user.id }}
</ng-container>

Alternative solution:

<ng-container *ngIf="(user | json) != '{}'">
    {{ user.id }}
</ng-container>