Page 1 of 1

Who is using Var2Json() and Json2Var()

Posted: Tue Feb 01, 2022 10:51 am
by rdonnay
I am not having consistent results with these functions.

It is very important that I can depend on these functions to handle conversion of arrays of dataobjects to json and vice-versa.

I wrote a webservice that needs to communicate via restful methods rather than soap.

Sometimes I get an IDSC, other times a runtime error inside the Xbase++ code.

Here is an example of a JSON object that causes a runtime error with Json2Var() :

Code: Select all

 { "data" :[
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"9K99", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"3L55", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"Suv            ", "Make" :"Ford           ", "Medallion" :"2P17", "Model" :"Escape         ", "Fuel" :"Hybrid  "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1A38", "Model" :"CVC            ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1A45", "Model" :"C-max          ", "Fuel" :"Hybrid  "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1B40", "Model" :"CVC            ", "Fuel" :"Gas     "},
{"Type" :"Suv            ", "Make" :"Ford           ", "Medallion" :"1C18", "Model" :"Escape         ", "Fuel" :"Hybrid  "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1C79", "Model" :"Escape         ", "Fuel" :"Hybrid  "},
{"Type" :"Minivan        ", "Make" :"Ford           ", "Medallion" :"1A14", "Model" :"Escape         ", "Fuel" :"Gas     "},
{"Type" :"Minivan        ", "Make" :"Ford           ", "Medallion" :"1A14", "Model" :"Escape         ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1A24", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1A55", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1A55", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"Suv            ", "Make" :"Ford           ", "Medallion" :"1B64", "Model" :"Escape         ", "Fuel" :"Hybrid  "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1C44", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1D29", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1D29", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"1D29", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"Suv            ", "Make" :"Ford           ", "Medallion" :"1E22", "Model" :"Escape         ", "Fuel" :"Hybrid  "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H98", "Model" :"Crown Victoria ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2H99", "Model" :"Crown Victoria ", "Fuel" :"        "},
{"Type" :"Suv            ", "Make" :"Ford           ", "Medallion" :"2J50", "Model" :"Escape         ", "Fuel" :"Gas     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2J50", "Model" :"               ", "Fuel" :"GAS     "},
{"Type" :"4Door Sed      ", "Make" :"Ford           ", "Medallion" :"2J85", "Model" :"               ", "Fuel" :"GAS     "}
], "result" :"Success", "error" :null}

Re: Who is using Var2Json() and Json2Var()

Posted: Thu Feb 17, 2022 10:23 am
by jdsoft
Hello Roger,

I use this verry extensively in my webserver.
I tested your sample data, and have no issues at all.
Even on Json data of 500Kb, no problems.

Re: Who is using Var2Json() and Json2Var()

Posted: Thu Feb 17, 2022 11:29 am
by rdonnay
Those functions have been working ok for the past 2 weeks.

Something would happen to my WebService that would destabilize everything and start causing IDSC's.
It would require a reboot of the computer and even the thunderbolt.

I narrowed it down to ClassDescribe() which is invoked by Var2Json.

It seemed to happen when making SQL calls to ADS within the WebService app.
After changing those calls to use the command interface of SqlQuery.exe via Runshell() the problems went away.