Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr
Letzter Beitrag:
vor 12 Monaten
Beteiligte Autoren:

VariantToJSON - Now not working

Startbeitrag von DerekT am 22.07.2017 16: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)

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


Re: VariantToJSON - Now not working - SOLVED

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.

von DerekT - am 23.07.2017 11:33
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.