Page 1 of 1

Best FWH functions for API, Hash, Curl

Posted: Sat Oct 30, 2021 5:42 pm
by Marc Venken
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)

Re: Best FWH functions for API, Hash, Curl

Posted: Sat Oct 30, 2021 6:03 pm
by leandro
Creo que es lo que necesitas

Code: Select all | Expand


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

Re: Best FWH functions for API, Hash, Curl

Posted: Sat Oct 30, 2021 6:11 pm
by Marc Venken
leandro wrote:Creo que es lo que necesitas

Code: Select all | Expand


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