Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appends _serializableMap {} to the objects of the given class after serializing #26

Open
ghost opened this issue Jul 23, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented Jul 23, 2020

No description provided.

@ghost ghost changed the title Appends _serializableMap {} to the given class after serializing Appends _serializableMap {} to the objects of the given class after serializing Jul 23, 2020
@delete
Copy link
Collaborator

delete commented Jul 24, 2020

Hi @mohitp-cci , can you give me an use case for this, please?

@ghost
Copy link
Author

ghost commented Jul 25, 2020

@delete
My Order class defination :
@serialize({})
export default class Order extends Serializable {
@SerializeProperty({
map: 'id',
})
private id!: string;

@SerializeProperty({
map: 'externalOrderID',
optional: true,
})
private externalOrderID?: string | null;

@SerializeProperty({
map: 'waypoints',
type: Waypoint,
list: true,
})
private waypoints!: Array;

set setID(id: string) {
this.id = id;
}

set setStatus(status: string) {
this.status = status;
}
}

i am deserialising the order object from the json.
order.deserialize(requestBody);

Request body json :
"body": "{"externalOrderID":98207,"type":"pickup_and_delivery","customer":{"externalCustomerID":7199889,"name":"John Smith","phone":null,"email":null},"waypoints":[{"scheduledAt":"2021-10-31T16:00:00.000Z","address1":"5210 TRADEMARK DRIVE, RALEIGH, NC","address2":null,"lat":35.7686299,"lng":-78.5487832,"city":"Raleigh","state":"KS","country":null,"zipcode":"27610","pickupDropoffOption":"pickup","position":1,"contactPerson":{"name":"John Smith","phone":"+15555555555"}}]}",

the deseriazed object contains _serializeMap":{}. Eg
{"_serializeMap":{},"externalOrderID":98207,"waypoints":[{"_serializeMap":{},"address1":"5210 TRADEMARK DRIVE, RALEIGH, NC","address2":null,"city":"Raleigh","state":"EA","country":null,"zipcode":"27610","lat":35.7686299,"lng":-78.5487832,"scheduledAt":"2021-10-31T16:00:00.000Z","contactPerson":{"_serializeMap":{}............

@dpopescu
Copy link
Owner

Let me if I understand correctly. You want the _serializeMap to be present or it's present right now and you want it removed?

@ghost
Copy link
Author

ghost commented Jul 25, 2020

@dpopescu It is present in the deserialized object, which should be removed.

@dpopescu
Copy link
Owner

@mohitp-cci got it and totally agree. It should not pollute the object's public API. It should be hidden under a Symbol and should not be enumerable. Thanks. When the private properties spec will be available natively in browser, the implementation should change to that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants