Is there a way to designate the serialized name (similar to @SerializedName
in Gson
) of a field in a model class when receiving JSON responses from a server?
For example, if the server response includes fields like start_date
or some_date
, but I want my model to have fields named startDate
or acquisitionDate
. In my Spring server, response model fields are annotated with
@SerializedName("start_date")
.
I am working with Angular 10
and using HttpClient
as shown below:
httpClient.get<MyModel[]>(environment.apiUrl + '/getData')
.pipe(map(models => models.map(m => Object.assign(new MyModel(), m)));