ExploreConsulting / netsuite-fasttrack-toolkit-ss2

NFT for SuiteScript 2.X
74 stars 20 forks source link

ensure 'id' exists when you json stringify a NSDAL object #53

Closed ShawnTalbert closed 3 years ago

ShawnTalbert commented 3 years ago

Noticed that currently JSON stringify only includes the protected _id property - whereas if we want to treat the JSON as a read-only instance of some NFT NSDAL type, it needs an id, not_id. For example, with mediator if I do a getCustomer command, it should return customer JSON that includes an id, so I can still use the Customer class on the client side for property code-completion. Granted, it's not a real NSDAL object but we know on the client side because it came from plain JSON so it's obviously not a real NSDAL record. Still useful for the shape (properties).

ShawnTalbert commented 3 years ago

Note I didn't try to prevent the _id field from also serializing but we certainly could. I figured that would be a bit more risky than simply adding id.