HOW TO IMPORT JSON TO DBF

309 views
Skip to first unread message

Vikram Chhajer

unread,
Dec 12, 2019, 9:31:24 AM12/12/19
to Harbour Users
Hello 
I have json File And Want to import to dbf . how to do ?

{"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"}


Thanks 
Vikram

jtlk...@gmail.com

unread,
Feb 12, 2025, 3:00:55 AM2/12/25
to Harbour Users
if anyone done this pls send sample

Jose Antonio Leon Tellez

unread,
Feb 12, 2025, 8:17:36 AM2/12/25
to harbou...@googlegroups.com
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

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/3c64b52e-600b-4b65-8859-5cab092e3d3f%40googlegroups.com.

Jose Antonio Leon Tellez

unread,
Feb 12, 2025, 9:07:31 PM2/12/25
to harbou...@googlegroups.com
Hi Jagadeesan,
--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

дипл.инж. Мирослав Р. Маричић, проф.

unread,
Feb 13, 2025, 4:57:53 AM2/13/25
to harbou...@googlegroups.com
  "Hello! Could you send me a link to a Harbour library that contains the functions hb_jsondecode(), hb_jsonencode(), and all other functions for working with JSON files, so I can download it? Thanks in advance 😀  


---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Jose Antonio Leon Tellez

unread,
Feb 14, 2025, 9:23:29 AM2/14/25
to harbou...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages