When I use JSON.stringify on a Parse.com query object, it only includes the "attributes" and ignores the rest. How do I stringify the entire object?
My query to Parse, logging the results with and without stringify:
// load races from Parse
var Events = Parse.Object.extend("Events");
var query = new Parse.Query(Events);
query.equalTo("theYear", currentYear);
query.ascending("sortOrder");
query.find({
success: function(results) {
forgeLog("Got "+results.length+" Events from Parse");
forgeLog("First object in array logged directly:");
forgeLog(results[0]);
forgeLog("First object in array with stringify:");
forgeLog(JSON.stringify(results[0]));
},
error: function(error) {
forgeLog("Error getting Events from Parse");
}
});
The object logged directly:
{ attributes:
{ Name: 'McCalls Motorworks',
raceId: '0',
sortOrder: 2,
theYear: 2012 },
_operations: {},
_dirty: {},
_hashedJSON: {},
_escapedAttributes: {},
cid: 'c0',
id: 'To6lLjzwQw',
createdAt: '2012-08-09T13:51:29.259Z',
updatedAt: '2012-08-10T13:23:07.280Z',
_setting: false,
_previousAttributes:
{ Name: 'McCalls Motorworks',
raceId: '0',
sortOrder: 2,
theYear: 2012 }
}
The object logged with stringify:
{"Name":"McCalls Motorworks","raceId":"0","sortOrder":2,"theYear":2012}
Update: I actually just tested myself and it works when I manually define the object by cut and pasting the first object and defining the variable myself. However, when I stringify the result directly after receiving it from Parse (as in example code), it only returns the attributes portion...yet the first object is what I copied directly from my console when logging the result from Parse before attempting to stringify.