Realm trigger with JSON.stringify

Hi,

I have a realm function that serializes a record into json to be sent somewhere.

However child objects don’t get serialized properly and show up as an empty object. But the value exists if I print the property on the child object.

Realm function logging location prop on the document and the location.latitude:
image

Log shows empty object in latitude for serialized location object but it prints the latitude fine:

Thanks,

I guess the document is in EJSON and JSON.stringify isn’t smart enough to figure it out.

Had to manually parse it:

var projectCopy = JSON.parse(JSON.stringify(changeEvent.fullDocument));
projectCopy.location.latitude = Number(changeEvent.fullDocument.location.latitude);
projectCopy.location.longitude = Number(changeEvent.fullDocument.location.longitude);

Is there an easier way?