Expanding on the previous solution
When I convert the example object to JSON from the answer above:
JSON.stringify(obj)
The output is:
{"_id":"3457"}
If I intend to transmit this data over a service and store it in a database, I prefer not to use the field name '_id'. Doing multiple translations on field names during storage is not ideal.
My question is, what would be a suitable naming convention for accessors to achieve better property names without compromising the accessor shortcut?
For instance:
private id: number;
public get g_id(): number {
return this.id;
}
public set s_id(value: number) {
this.id = value;
}