Skip to content

Ability to ignore constructor class map #686

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/ParseObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -1403,14 +1403,16 @@ class ParseObject {
* @param {Object} json The JSON map of the Object's data
* @param {boolean} override In single instance mode, all old server data
* is overwritten if this is set to true
* @param {boolean} ignoreClassMap ignores current classMap. Object will be
* returned as an instance of Parse.Object
* @static
* @return {Parse.Object} A Parse.Object reference
*/
static fromJSON(json, override) {
static fromJSON(json, override, ignoreClassMap = false) {
if (!json.className) {
throw new Error('Cannot create an object without a className');
}
var constructor = classMap[json.className];
var constructor = ignoreClassMap ? undefined : classMap[json.className];
var o = constructor ? new constructor() : new ParseObject(json.className);
var otherAttributes = {};
for (var attr in json) {
Expand Down