JSON.Stringify drops values
Hi
I want to use JSON.Stringify for later data transmission to the panel.
My data is an object of nested arrays of objects. For problem description however, I will use simpler data as the result is the same:
var defs = ["One","Two"];
var testObj = {
Z1_1:[defs,defs],
Z1_2:[defs,defs],
Z2_1:[defs,defs]
};
var defs is a 'template' array with which I populate the object.
Then I Stringify it:
var TSTR = JSON.Stringify(testObj);
IR.Log("TSTR JSON String:");
IR.Log(TSTR);
Here is the problem - the output is:
TSTR JSON String:
{"Z1_1":[["One", "Two"], {}], "Z1_2":[{}, {}], "Z2_1":[{}, {}]}
Apparently JSON.Stringify drops out simmilar data in following arrays.
Accordingly, testing the same code in VS Code, the output is correct:
TSTR JSON String:
{"Z1_1":[["One","Two"],["One","Two"]],"Z1_2":[["One","Two"],["One","Two"]],"Z2_1":[["One","Two"],["One","Two"]]}
If I use different arrays declarations for each object property (i.e. defs1, defs2, defs3 etc.) the output will be correct. Unfortunately I cannot do that as the aim is to dynamically add more properties to testObj with the same template array,
Can you please advice on this - is there any workaround this? Is there something I am missing? Or is this a bug or limitation in iRidium?
I am looking forward to see the solution!
Thanks!
Сервис поддержки клиентов работает на платформе UserEcho
Hello.
Thank you for the information. The key must be a string, i.e. the code must look like this:
However, we will check the operation of JSON.Stringify and report the result.
Use this code:
The JSON.Stringify method uses recursive nesting protection, but it captures objects at the same level.
Hi,
That works perfect now.
Thank you!