mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Handle both strings and objects in Base.importJson().
And keep returning strings from #exportJson().
This commit is contained in:
parent
9d2fd2f675
commit
9adfc01c8d
1 changed files with 2 additions and 4 deletions
|
@ -61,9 +61,6 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
|
||||
// To support JSON.stringify:
|
||||
toJSON: function() {
|
||||
// TODO: We should probably have exportJson() / importJson() deal with
|
||||
// objects rather than strings too, so we can just delegate to those
|
||||
// here.
|
||||
return Base.serialize(this);
|
||||
},
|
||||
|
||||
|
@ -382,7 +379,8 @@ this.Base = Base.inject(/** @lends Base# */{
|
|||
},
|
||||
|
||||
importJson: function(json) {
|
||||
return Base.deserialize(JSON.parse(json));
|
||||
return Base.deserialize(
|
||||
typeof json === 'string' ? JSON.parse(json) : json);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue