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
Tom
Posts: 1165
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

#11 Post by Tom »

No, the Chilkat library is available as an ActiveX component, and that can be (easily!) used from Xbase++. You can use the FoxPro samples, they only need few adaptions.

Code: Select all

FUNCTION UseChilkat()
LOCAL o := CreateObject('Chilkat_9_5_0.Global')
o:UnlockBundle('MyUnlockCodeOrTestText')
IF o:UnlockStatus # 2
  MsgBox('Chilkat not avialable')
  RETURN .F.
ENDIF

* go on and use components

RETURN .T.
Best regards,
Tom

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

Diego Euri Almanzar
Posts: 155
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

#12 Post by Diego Euri Almanzar »

Hello Tom

Excellent, many thanks.

Regan Cawkwell informs me that a free version of the Chilkat library may appear. So far, what I've researched costs $300. Do you have any idea of ​​a free version?

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

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

#13 Post by unixkd »

The Chilkat has ActiveX version that can be used very easily in Xbase++. I use a lot of their free components and it is fun.

Joe

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

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

#14 Post by skiman »

Hi,

Some of them are free.
Go to https://www.chilkatsoft.com/refdoc/activex.asp for a list of all the classes.
When you hover above a class, you get a tooltip with the information if it is free or not.
Last edited by skiman on Wed Mar 30, 2022 1:29 am, edited 1 time in total.
Best regards,

Chris.
www.aboservice.be

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

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

#15 Post by unixkd »

In addition foxpro is Xbase so the sample code can be translated to Xbase++ very easily e.g.

FOXPRO SAMPLE CODE
===================

Function StockQuote()
LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lnSuccess
LOCAL lcResponseJson

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loRest = CreateObject('Chilkat_9_5_0.Rest')

* Connect to the REST server.
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("www.alphavantage.co",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF

* Get a stock quote:
* Sending GET request to https://www.alphavantage.co/query?funct ... my_api_key
lnSuccess = loRest.AddQueryParam("function","TIME_SERIES_DAILY")
lnSuccess = loRest.AddQueryParam("symbol","AAPL")
lnSuccess = loRest.AddQueryParam("apikey","my_api_key")
lcResponseJson = loRest.FullRequestNoBody("GET","/query")
IF (loRest.LastMethodSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
Return

XBASE++ TRANSLATION SAMPLE CODE
===============================

Function StockQuote()
LOCAL loRest
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL lnSuccess
LOCAL lcResponseJson

* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loRest := CreateObject('Chilkat_9_5_0.Rest')

* Connect to the REST server.
lnBTls := 1
lnPort := 443
lnBAutoReconnect = 1
lnSuccess = loRest:Connect("www.alphavantage.co",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1)
? loRest:LastErrorText
RELEASE loRest
CANCEL
ENDIF

* Get a stock quote:
* Sending GET request to https://www.alphavantage.co/query?funct ... my_api_key
lnSuccess := loRest:AddQueryParam("function","TIME_SERIES_DAILY")
lnSuccess := loRest:AddQueryParam("symbol","AAPL")
lnSuccess := loRest:AddQueryParam("apikey","my_api_key")
lcResponseJson := loRest:FullRequestNoBody("GET","/query")
IF (loRest:LastMethodSuccess <> 1)
? loRest:LastErrorText
RELEASE loRest
CANCEL
ENDIF
Return


Joe

User avatar
rdonnay
Site Admin
Posts: 4722
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

#16 Post by rdonnay »

I would very much like to help with this but I am bogged down in a big project with a deliverable expected on April 9.

I am working a lot with JSON on this project and expect to have more tools for eXpress++ customer in a few weeks.

What would help me is if XbpHtmlViewer() would support JSON formatting when viewing it in the ActiveX web browser.
Both Edge and Chrome support this, but the ActiveX browser does not.
The eXpress train is coming - and it has more cars.

User avatar
Tom
Posts: 1165
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

#17 Post by Tom »

Both Edge and Chrome support this, but the ActiveX browser does not.
I heard rumours that Alaska is working on a replacement for the IE control in XbpHtmlViewer using the Chromium browser/framework.
Best regards,
Tom

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

User avatar
rdonnay
Site Admin
Posts: 4722
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

#18 Post by rdonnay »

That would be a welcome addition to Xbase++.

Working with Json is actually a dream come true, even when not using Javascript.
Var2Json() and Json2Var() are really the future of my development projects.
It is the best multipart/form response for debugging I have ever seen, even though it is considered light-weight.
Much better than XML.
It works for everything I have thrown at it, except I have to use Edge or Chrome to format it for proper viewing.
I want to add support in WTF to view, properly formatted, Json objects.
The eXpress train is coming - and it has more cars.

Diego Euri Almanzar
Posts: 155
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

#19 Post by Diego Euri Almanzar »

Thanks, Tom, unix, skiman, and rdonnay.

I have learned a lot from all your texts.

Now, maybe I didn't understand correctly, but as explained by RDONNAY it is preferable to use the Xbase++ and Express++ tools for handling JSON.

I know ActiveX is easy to use, but I prefer to use native tools. I repeat, I think RDONNAY prefers the use of native tools, I think for RDONNAY it supports the use of JSON in the XBASE++ environment

If I misunderstood, please correct me.

User avatar
rdonnay
Site Admin
Posts: 4722
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

#20 Post by rdonnay »

I know ActiveX is easy to use, but I prefer to use native tools.
I prefer to use native tools also, this is why I have very little usage of third-party tools in eXpress++.

However, there is 1 exception: RmChart.
This is a FREE ActiveX OCX that provides exceptional graphing capability and has always worked perfectly under all Windows and Xbase++ releases.

DCRMCHART is very useful in many of my customer applications.

I am going to make 1 more exception: Chilkat JSON.
I use this only for formatting JSON code to make it more readable in a text editor or in the DCHMTLVIEWER.
This is also a free ActiveX object.
I will be adding support to eXpress++ for viewing DataObjects in JSON format in the debugger (WTF).
If Chilkat JSON is installed, it will also display properly formatted JSON.
The eXpress train is coming - and it has more cars.

Post Reply