Irwin1985 / JSONFox

JSONFox is a free JSON parser written in Visual FoxPro 9.0
59 stars 34 forks source link

JsonToCursor #28

Closed vicosx12 closed 2 years ago

vicosx12 commented 2 years ago

JsonToCursor always carries a single record. It should insert all elements of the array into the cursor.

Irwin1985 commented 2 years ago

can you please post some example?

vicosx12 commented 2 years ago

Do jsonfox.app _Screen.Json.netScanner = .T.

Text To myJSONString NoShow TextMerge [{"cui":6578829,"data":"2022-06-21","denumire":"B SOFT SRL","adresa":"JUD. CALARASI, MUN. OLTENITA, BLD. REPUBLICII, BL.REPUBLICII, SC.B, ET.5","nrRegCom":"J51/830/1994","codPostal":"915400","stare_inregistrare":"INREGISTRAT din data 12.12.1994","scpTVA":true,"data_inceput_ScpTVA":"1995-10-01","data_sfarsit_ScpTVA":" ","data_anul_imp_ScpTVA":" ","mesaj_ScpTVA":"platitor IN SCOPURI de TVA la data cautata","dataInceputTvaInc":"2013-01-01","dataSfarsitTvaInc":"","dataActualizareTvaInc":"2012-12-27","dataPublicareTvaInc":"2012-12-28","tipActTvaInc":"Inregistrare","statusTvaIncasare":true,"dataInactivare":" ","dataReactivare":" ","dataPublicare":" ","dataRadiere":" ","statusInactivi":false,"dataInceputSplitTVA":"","dataAnulareSplitTVA":"","statusSplitTVA":false,"iban":"","statusRO_e_Factura":false},{"cui":37869879,"data":"2022-06-21","denumire":"CEMATICO INVEST SRL","adresa":"JUD. CALARASI, MUN. OLTENITA, STR. PESCARILOR, NR.23, BL.M6, SC.A, ET.PARTER, AP.3","nrRegCom":"","telefon":"","fax":"","codPostal":"","act":"","stare_inregistrare":"","scpTVA":false,"data_inceput_ScpTVA":"","data_sfarsit_ScpTVA":"","data_anul_imp_ScpTVA":"","mesaj_ScpTVA":"nu figureaza in registre ","dataInceputTvaInc":"","dataSfarsitTvaInc":"","dataActualizareTvaInc":"","dataPublicareTvaInc":"","tipActTvaInc":"","statusTvaIncasare":false,"dataInactivare":" ","dataReactivare":" ","dataPublicare":" ","dataRadiere":" ","statusInactivi":false,"dataInceputSplitTVA":"","dataAnulareSplitTVA":"","statusSplitTVA":false,"iban":"","statusRO_e_Factura":false},{"cui":14916343,"data":"2022-06-21","denumire":"EXPERT SOFTWARE COMPANY S.R.L.","adresa":"JUD. CALARASI, MUN. OLTENITA, STR. ARGESULUI, NR.52-58, BL.32, ET.4, AP.14","nrRegCom":"J51/446/2003","telefon":"0723701373","codPostal":"915400","stare_inregistrare":"INREGISTRAT din data 11.09.2003","scpTVA":true,"data_inceput_ScpTVA":"2002-10-01","data_sfarsit_ScpTVA":" ","data_anul_imp_ScpTVA":" ","mesaj_ScpTVA":"platitor IN SCOPURI de TVA la data cautata","dataInceputTvaInc":"","dataSfarsitTvaInc":"","dataActualizareTvaInc":"","dataPublicareTvaInc":"","tipActTvaInc":"","statusTvaIncasare":false,"dataInactivare":" ","dataReactivare":" ","dataPublicare":" ","dataRadiere":" ","statusInactivi":false,"dataInceputSplitTVA":"","dataAnulareSplitTVA":"","statusSplitTVA":false,"iban":"","statusRO_e_Factura":false}] EndText

*oJson=_Screen.Json.Parse(myJSONString) _Screen.Json.JsonToCursor(myJSONString, 'Anaf_WS', 0) && had to retrieve all 3 records in the cursor

În mar., 21 iun. 2022 la 12:33, Irwin Rodríguez @.***> a scris:

can you please post some example?

— Reply to this email directly, view it on GitHub https://github.com/Irwin1985/JSONFox/issues/28#issuecomment-1161502615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPBEVAKC5NTSAXEUO5FQZDVQGEADANCNFSM5ZLUDIBQ . You are receiving this because you authored the thread.Message ID: @.***>

--

Cu stima / Best regards,

*V*ilciu Constantin Economist 0720.471.737

Irwin1985 commented 2 years ago

The first element of the array determines the structure of the cursor, that said, I can see that in the first element there is a property called data_inceput_ScpTVA whose value clearly looks like a date but the second element has an empty string assigned with which there is already incompatibility between date and string.

I think you could solve this parsing error by adding a fake date in those properties e.g.: 1953-01-01 and then after creating the cursor do a replace all for those columns with an empty date like CTOD('{}').