Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML format

This forum is for eXpress++ general support.
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4775
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#21 Post by rdonnay »

Here is an updated DC_InspectObject() function.

This has been improved to view objects with 2 Tabpages: Browse and Json

When you use WTF for debugging an object and click on the object in the debug window, it will invoke DC_InspectObject().
Now you can view the object using either the older One-to-Many browser, or Formatted Json.

Copy _DCARRAY.PRG to your \exp20\source\dclipx folder.
Run Build20.bat to rebuild DCLIPX.DLL

_dcarray.zip

If you have the Chilkat Json ActiveX control installed, it will display formatted JSON, otherwise it will display in the format created by Var2Json(), i.e. Unformatted.
The eXpress train is coming - and it has more cars.

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#22 Post by Diego Euri Almanzar »

Excellent DONNAY, all the explanations and information on this subject have made me an expert. I am very grateful.

On the other hand, please point me to a good site, where I can download the RMCART OCX.

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

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#23 Post by rdonnay »

where I can download the RMCART OCX.
Look in \exp20\samples\rmchart
The eXpress train is coming - and it has more cars.

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#24 Post by Diego Euri Almanzar »

Excellent, thank you very much, RDONNAY.

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#25 Post by Diego Euri Almanzar »

Hello everyone!

With the excellent tools of Express, or Xbase++, I can read a table and convert each of its records into JSON.

Now, I would like to know how to save a JSON of several records, on the hard disk, and how to reuse, or read, this JSON that will be stored on disk. For example, how do I save the following information to disk, and then retrieve it back into memory when I want to use it in a query?

var employeeJson = [
{
"Employee Name":"Rahul Singh",
"Address":"Hyderabad",
"Email ID":"rahul.singh@gmail.com",
"Age":25
},
{
"Employee Name":"Pawan Patil",
"Address":"Mumbai",
"Email ID":"pawan.patil@gmail.com",
"Age":27
},
{
"Employee Name":"karl Jablonski",
"Address":"Seattle",
"Email ID":"jablonski.karl@gmail.com",
"Age":25
},
{
"Employee Name":"John Smith",
"Address":"New York",
"Email ID":"smith.jh@gmail.com",
"Age":22
}];


How do I save the above on disk, or how can I read it when I want to consult it?

Best regards.

User avatar
Tom
Posts: 1205
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#26 Post by Tom »

Diego, do you use the (free) chilkat library? This will generate the code to parse your JSON. Select "FoxPro" as the language and paste your var:

http://tools.chilkat.io/jsonParse

@Roger: Alaska just published a new "XbpHtmlViewer2" class as an asset which uses Edge components instead of the old IE. Unfortunately, this control seems also not to be able to show JSON like some browsers do:
Browsertest.png
Browsertest.png (40.02 KiB) Viewed 5861 times
Besides: I changed eXpress++ to use the asset in DCHTMLVIEWER. Works excellent!
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#27 Post by Diego Euri Almanzar »

Hello Tom,

Thank you in advance for your great help.

Recently, I had an unfortunate event, with a third party product. And, although the library that you indicate is free, I want to work with Xbase, or with Express. My mind is closed regarding other products.

Other than that, I don't really want to see output on the screen from the content of a JSON. I just want to know how to produce a JSON string from multiple records, and how to save it to disk, when this string is ready.

When I achieve it, the JSON that is on disk, I will display it through a Bootstrap table, in my new CXP application. If you can help me generate a JSON from more than one record, and store it on disk, I'd appreciate it.

On the other hand, on the subject "How to use PGDBE in CXP programs", I just copied the answer Alaska gave me. PGDBE seems to work fine, in CXP programs.

User avatar
Tom
Posts: 1205
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#28 Post by Tom »

Hi, Diego.

Great to hear your CXP now runs with the PGDBE!

If you want to work with the JSON-response your get, use Json2Var, which will turn the JSON data into an array of dataobjects:

Code: Select all

aO := Json2Var(cJson) // cJson is everything from "[{" to "}]"
FOR n := 1 TO Len(aO) // aO should have the lenght "4" in your sample, every item is an object with iVars named from the JSON
 ? aO[n]:GetNoIVar("Employee Name") // since var names with blanks can't be handled directly
  ? aO[n]:addresss
NEXT
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Diego Euri Almanzar
Posts: 174
Joined: Thu Nov 05, 2020 10:51 am
Location: DOMINICAN REPUBLIC

Re: Examples in Xbase++ code, or Express++, to help me understand how to send and receive information in JSON and XML fo

#29 Post by Diego Euri Almanzar »

Hello Tom,

Excellent, that's exactly what I needed.

Thank you very much.

Post Reply