Best FWH functions for API, Hash, Curl

Best FWH functions for API, Hash, Curl

Postby Marc Venken » Sat Oct 30, 2021 5:42 pm

I was able to connect and change my shopdata with a API instruction.

The data string looks like this :

cData := '{"images":["5101000.jpg"],"sku":"skuData","ean":"98745123456","name":"Noyca","description":"Memo<b>Data</b>"}'

the API docs gives this a example data :

{
"model": "string",
"sku": "string",
"ean": "string",
"name": "string",
"description": "string",
"introDescription": "string",
"extraDescription": "string",
"metaTitle": "string",
"metaKeyword": "string",
"metaDescription": "string",
"quantity": 0,
"categoryId": 0,
"price": 0,
"purchasePrice": 0,
"status": true,
"taxRate": 0,
"manufacturerId": 0,
"width": 0,
"height": 0,
"weight": 0,
"images": [
"ImageOne"
],
"imagesAlt": [
"ImageOneAlt"
],
"resources": [
{
"resourceKey": "key",
"resourceValue": "value",
"resourceType": "type"
}
]
}

My question : Look at the last data : resources. It has several subdata's like Key, Value, Type....

I suspect that FWH has functions already build for generating this kind of strings, thinking that the data origin in my case sits in a dbf.
I know that i have to make a matching function for the dbf data to the online data.

Do these functions exist ? of do I have to make a function myself to generate this kind of string (cData as example)
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1428
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Best FWH functions for API, Hash, Curl

Postby leandro » Sat Oct 30, 2021 6:03 pm

Creo que es lo que necesitas

Code: Select all  Expand view

cData := hb_jsonEncode( hData )
.....
Local := hData := {=>}
hb_jsondecode(cData,@hData )
 
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1669
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia

Re: Best FWH functions for API, Hash, Curl

Postby Marc Venken » Sat Oct 30, 2021 6:11 pm

leandro wrote:Creo que es lo que necesitas

Code: Select all  Expand view

cData := hb_jsonEncode( hData )
.....
Local := hData := {=>}
hb_jsondecode(cData,@hData )
 


Hey,
I can read the data and see it in xbrowse, but I want to put ALL fields into a dbf, because dbf I can handle/workwith.
Hashes I can work when they are simple like :

h2 := FW_RecToHash(), ;
oBrwT:LButtonUp(), ;
h1["positie"] = "100" ,;
FW_HashToRec( h1 ), ;
DBGOTO( nPos1 ), ;
FW_HashToRec( h2 ), ;

In the large datafile that comes from my site the hashes are more complex. I think like multidimensional or so and that is difficult for now
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1428
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Silvio.Falconi and 59 guests

cron