Hi Vikram,
response:=
{"ewbNo":241162875406,"ewbDate":"12/12/2019 06:51:00 PM","status":"ACT","genGstin":"27AGJPC3158J1ZC","docNo":"CKF1905671","docDate":"12/12/2019","delPinCode":110031,"delStateCode":27,"delPlace":"","validUpto":"","extendedTimes":0,"rejectStatus":"N"}nLen := hb_jsondecode( response, @res )
if nlen=0
msginfo("Not found")
return
endif
ewbNo :=res["ewbNo
"]
ewbDate:=res["ewbDate
"]
status :=
res["status"]
genGstin:= res["genGstin"]
docNo := res["docNo"]
docDate:= res["docDate"]
delPinCode:= res["delPinCode"]
delStateCode:= res["delStateCode "]
delPlace:= res["delPlace"]
validUpto:= res["validUpto"]
extendedTimes:= res["extendedTimes"]
rejectStatus:= res["status"]
then
REPLACE ......
is a basic solution.
there are other examples, when there are many records: (see FOR EACH o IN paises)
*--------------------*
function readcountry()
*---------------------*
doc = CreateObject( "MSXML2.DOMDocument" )
ohttp = CreateObject( "MSXML2.XMLHTTP" )
If (Empty( ohttp))
MsgStop( 'No se Pudo Crear el Objeto ohttp; se Cancela el Programa' )
Return( .f. )
Endif
If (Empty( ohttp))
MsgStop( 'No se Pudo Crear el Objeto ohttp; se Cancela el Programa' )
Return( .f. )
Endif
oHttp:Open ("GET", "
https://covid19.mathdro.id/api/countries", .f.)
ohttp:Send()
mstatus=ohttp:STATUS
if ohttp:STATUS = 200 .or. mstatus=520
response:=ohttp:responseText
if mstatus=520
msginfo(response)
return
endif
else
MsgStop( "Error: Status "+str(mstatus,10) )
endif
if (Empty( response ) )
MsgStop( "Error: Respuesta esta VACIA. Status "+str(mstatus,10) )
return
End
nLen:=0
res:={}
o=0
msginfo(response)
nLen := hb_jsondecode( response, @res )
paises:=res["countries"]
alert("Hay "+tran(len(paises),"999,999")+" paises")
aCountry:={}
FOR EACH o IN paises
cname:=""
ciso2:=""
ciso3:=""
if "name"$o
cname :=o["name"]
endif
if "iso2"$o
ciso2 :=o["iso2"]
endif
if "iso3"$o
ciso3 :=o["iso3"]
endif
AADD(aCountry,{cname,ciso2,ciso3})
NEXT
*** REVISAR LOS PRIMEROS 10 valores del array
CLEAR
FOR i=1 to 10
@i,0 say "name "+aCountry[i,1]+" iso2 "+aCountry[i,2]+" iso3 "+aCountry[i,3]
NEXT
ohttp := NIL
Release ohttp
WAIT ""
return
Regards,
Jose Antonio Leon Tellez