Skip to content
Merged
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
11 changes: 8 additions & 3 deletions js/rpg_core/JsonEx.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ JsonEx._encode = function(value, circular, depth) {
value['@'] = constructorName;
}
for (var key in value) {
if (value.hasOwnProperty(key) && !key.match(/^@./)) {
if ((!value.hasOwnProperty || value.hasOwnProperty(key)) && !key.match(/^@./)) {
if(value[key] && typeof value[key] === 'object'){
if(value[key]['@c']){
circular.push([key, value, value[key]]);
Expand Down Expand Up @@ -173,14 +173,16 @@ JsonEx._decode = function(value, circular, registry) {
if (type === '[object Object]' || type === '[object Array]') {
registry[value['@c']] = value;

if (value['@']) {
if (value['@'] === null) {
value = this._resetPrototype(value, null);
} else if (value['@']) {
var constructor = window[value['@']];
if (constructor) {
value = this._resetPrototype(value, constructor.prototype);
}
}
for (var key in value) {
if (value.hasOwnProperty(key)) {
if (!value.hasOwnProperty || value.hasOwnProperty(key)) {
if(value[key] && value[key]['@a']){
//object is array wrapper
var body = value[key]['@a'];
Expand All @@ -206,6 +208,9 @@ JsonEx._decode = function(value, circular, registry) {
* @private
*/
JsonEx._getConstructorName = function(value) {
if (!value.constructor) {
return null;
}
var name = value.constructor.name;
if (name === undefined) {
var func = /^\s*function\s*([A-Za-z0-9_$]*)/;
Expand Down