PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → VariantToJSON - Now not working
VariantToJSON - Now not working
Débuté par DerekT, 22 juil. 2017 18:41 - 1 réponse
Posté le 22 juillet 2017 - 18:41
WDv22 - 01A220063m

Yesterday this was working fine.
Only thing that has changed is that M$ applied the 'creators update' without so much as a by your leave.

I have a multi-select looper, on save I loop through this and add each selected row to an array and execute the following code.

//If selections have been made IF ArrayCount(clMatching.m_ArrEssentials) > 0 THEN //Store the array content lvArrContent = clMatching.m_ArrEssentials //Update match string with the all selections as JSON clMatching.SET_JSONEssentials = VariantToJSON(lvArrContent) END
Yesterday no problem - today I get the fatal error.....

Error at line 17 of Click btnSave process.
VariantToJSON function called.
The JSON serialization does not allow the 'object' elements.

My understanding that it is supposed to do exactly what the error says it cannot.

I assume that 'object' is referring to the class - I have tried this as a class Property and class Method but get the same error.

Yesterday it saved it as [ { "nID":142 }, { "nID":143 }, { "nID":144 } ]

Any thoughts
Posté le 23 juillet 2017 - 13:33
After a bit more playing about my findings are that - much as the error implied - VariantToJSON, or for that matter Serialize(), does not work with class members or methods.

Moved the required variables to the window declaration and revised the code to use these and all works as expected.

Downside is that it does mean that I now require repetitive declarations in all windows that use the class functionality which is a shame.
Interestingly a small test indicates that I could move everything from the Class to a set of Global Procedures and that this would function correctly.

Any clever people out there have an insight why this should be a no-no for classes.