Hello,
I would expect that JSON.encode(jsObj) function that does not modify the object that is passed as a parameter (e.g. it is a function without side-effects).
Using below code I can confirm that some JSON properties are removed from jsObj after calling JSON.encode(jsObj).
To prove this behavior, I created two string representations of the jsObj, that are encoded using pure native JavaScript stringify() function - BEFORE call and AFTER call.
Then I compared these two strings (BEFORE and AFTER) strings and found they are different.
In this case, properties with names like "_recordComponents_isc_CalculationResultGrid" are removed!
Properties highlighted in red are removed from jsObj AFTER calling JSON.ecnode(jsObj):
Isn't this bug?
Is it described somewhere why this happens?
In our case this caused some bug that I can workaround by first creating clone of the jsObj.
Milan
I would expect that JSON.encode(jsObj) function that does not modify the object that is passed as a parameter (e.g. it is a function without side-effects).
Using below code I can confirm that some JSON properties are removed from jsObj after calling JSON.encode(jsObj).
To prove this behavior, I created two string representations of the jsObj, that are encoded using pure native JavaScript stringify() function - BEFORE call and AFTER call.
Then I compared these two strings (BEFORE and AFTER) strings and found they are different.
In this case, properties with names like "_recordComponents_isc_CalculationResultGrid" are removed!
Code:
GWT.log("BEFORE:" + stringify(jsObj)); String encodedString = JSON.encode(jsObj); GWT.log("AFTER :" + stringify(jsObj)); private final static native String stringify(JavaScriptObject obj) /*-{ return JSON.stringify(obj); }-*/;
Code:
"outputs": [ { "resultName": "Ref", ... "_recordComponents_isc_CalculationResultGrid_0": { "warnings": { "isNullMarker": true, "$669": "isc_CalculationResultGrid_0_body", "$81x": 1 }, ... }
Is it described somewhere why this happens?
In our case this caused some bug that I can workaround by first creating clone of the jsObj.
Milan
Comment