Who is using Var2Json() and Json2Var()

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Who is using Var2Json() and Json2Var()

#1 Post 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}
The eXpress train is coming - and it has more cars.

User avatar
jdsoft
Posts: 116
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

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

#2 Post 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.
Regards,
Jack Duijf

User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#3 Post 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.
The eXpress train is coming - and it has more cars.

Post Reply