Dear Sirs
How can I save following json data to dbf ?
{"ok":true,"result":[{"XXXX5086":8673,
"message":{"message_id":4,"from":{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476180184,"text":"\/text","entities":[{"type":"bot_command","offset":0,"length":5}]}},{"XXXX5086":8674,
"message":{"message_id":5,"from":{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476180228,"text":"hi"}},{"XXXX5086":8675,
"message":{"message_id":8,"from":{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476187294,"text":"How to Save Json to dbf"}}]}
Thanks & Regards
Yunus
How to Save Json data to dbf? (Solved)
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
How to Save Json data to dbf? (Solved)
Last edited by dagiayunus on Sun Oct 16, 2016 9:40 pm, edited 1 time in total.
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04
Re: How to Save Json data to dbf?
in memo field.
Regards
Regards
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
Re: How to Save Json data to dbf?
Dear Sir, Hampauito
I want to replace certain value in particular field from json data
for example fields , message_id , id, , textmsg etc.
Regards
Yunus
I want to replace certain value in particular field from json data
for example fields , message_id , id, , textmsg etc.
Regards
Yunus
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04
- TOTOVIOTTI
- Posts: 334
- Joined: Fri Feb 05, 2010 11:30 am
- Location: San Francisco - Córdoba - Argentina
Re: How to Save Json data to dbf?
Esto funcióna correctamente:
FUNCTION NEXO()
LOCAL URL:="http://xxx.xxx.xxx.xxx/testing/distribu ... rProductos"
LOCAL oDoc:=CreateObject("MSXML2.DOMDocument")
LOCAL oHttp:=CreateObject("MSXML2.XMLHTTP"),cRespuesta,aProductos:=""
oHttp:Open("GET",URL,.F.)
oHttp:SetRequestHeader("Accept" ,"application/xml")
oHttp:SetRequestHeader("Content-Type","application/json")
oDoc:async:=.f.
oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
oHttp:Send(oDoc:xml)
cRespuesta:=Alltrim(oHttp:responseText)
hb_jsondecode(cRespuesta,@aProductos)
XBROWSE(aProductos["productos"])
RETURN NIL
De la matriz aProductos, la puedes llevar a la DBF.
Espero te sea útil...
Roberto
FUNCTION NEXO()
LOCAL URL:="http://xxx.xxx.xxx.xxx/testing/distribu ... rProductos"
LOCAL oDoc:=CreateObject("MSXML2.DOMDocument")
LOCAL oHttp:=CreateObject("MSXML2.XMLHTTP"),cRespuesta,aProductos:=""
oHttp:Open("GET",URL,.F.)
oHttp:SetRequestHeader("Accept" ,"application/xml")
oHttp:SetRequestHeader("Content-Type","application/json")
oDoc:async:=.f.
oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
oHttp:Send(oDoc:xml)
cRespuesta:=Alltrim(oHttp:responseText)
hb_jsondecode(cRespuesta,@aProductos)
XBROWSE(aProductos["productos"])
RETURN NIL
De la matriz aProductos, la puedes llevar a la DBF.
Espero te sea útil...
Roberto
Re: How to Save Json data to dbf?
I believe that to do something like:
JSON DATA
To save
JSON DATA
Code: Select all
{"ok":true,
"result":[
{"XXXX5086":8673,
"message":
{"message_id":4,"from":
{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},
"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476180184,"text":"\/text","entities":[{"type":"bot_command","offset":0,"length":5}]}},
{"XXXX5086":8674,
"message":
{"message_id":5,"from":
{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476180228,"text":"hi"}},
{"XXXX5086":8675,
"message":
{"message_id":8,"from":
{"id":294425086,"first_name":"Yunus","last_name":"Dagia"},"chat":{"id":294425086,"first_name":"Yunus","last_name":"Dagia","type":"private"},"date":1476187294,"text":"How to Save Json to dbf"}
}
]
}
Code: Select all
FUNCTION SaveJSONData(cJSON)
LOCAL hJSON
cDBFFrom := "from"
cDBFChat := "chat"
HB_JSONDecode( cJSON, @hJSON )
FOR i := 1 TO Len( hJSON["result"] )
hData := hJSON["result"][i]["message"]
nMessageID := hData["message_id"]
hFrom := hData["from"]
FOR EACH x IN hFrom
(cDBFFrom)->&x:__enumKey() := x
NEXT
hChat := hData["chat"]
FOR EACH x IN hChat
(cDBFChat)->&x:__enumKey() := x
NEXT
NEXT
RETURN
Re: How to Save Json data to dbf?
Here is an example provided by Mr.Rao
http://forums.fivetechsupport.com/viewt ... 19#p191101
http://forums.fivetechsupport.com/viewt ... 19#p191101
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
Re: How to Save Json data to dbf?
Dear Anser,
I followed sample provide by Mr.Rao but... following error accrued
Error BASE/1003 Variable does not exist: TRUE
hHash := &cStr <= error accure on this line.
May be the structure of json string of Mr.Rao is different than mine.
Regards
Yunus.
I followed sample provide by Mr.Rao but... following error accrued
Error BASE/1003 Variable does not exist: TRUE
hHash := &cStr <= error accure on this line.
May be the structure of json string of Mr.Rao is different than mine.
Regards
Yunus.
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04
Re: How to Save Json data to dbf?
Try
Regards
Code: Select all
cStr:= StrTran(StrTran(cStr, ":false", ".F."), ":true", ".T.")
-
- Posts: 69
- Joined: Wed Nov 19, 2014 1:04 pm
- Contact:
Re: How to Save Json data to dbf?
Dear hmpaquito
Thanks for your reply.
I couldn't understand multi layer HASH jo just use simple string.
Telegram API using fivewin (without using any LIB)
http://forums.fivetechsupport.com/viewt ... =3&t=33056
Regards
Yunus.
Thanks for your reply.
I couldn't understand multi layer HASH jo just use simple string.
Telegram API using fivewin (without using any LIB)
http://forums.fivetechsupport.com/viewt ... =3&t=33056
Regards
Yunus.
Dagia Yunus.
Rajkot, India
FWH 17.04
Rajkot, India
FWH 17.04