Hi to all,
may somebody help me.
I have this JSON file:
{
"version": "3.1.0",
"sync-datetime": "2019-11-06 09:23:48",
"message": "",
"messages": [
],
"error": false,
"
"invoices": [
{
"id_customer": "26518",
"id_ow": "97",
"nr_customer": "C101",
"company": "Cliente 2",
"rows": [
{
"id_invoice_details": "24399",
"id_invoice": "12859",
"description": "Riga libera",
"total": "20.
},
{
"id_invoice_details": "24391",
"id_invoice": "12859",
"description": "Riga libera",
"total": "20.
}
]
I can read "rows" lines of invoice?
many thanks.
G.
Is it possibile I copy and past maybe wrong.
But the question is to read "rows" inside the "invoice "array.
I can read "invoice" fields but I don't know how I can read "rows" fields.
This is my question.
thx.
G.
Example below is INVOICES array.
oJsonArray = ResultObject:GetJsonArray("invoices").
DO i = 1 TO oJsonArray:LENGTH:
oNestObject1 = OJsonArray:GetJsonObject(i).
CREATE doctst.
ASSIGN documento = oNestObject1:GetJsonText('id_invoice').
doctst.dt_numdoc = oNestObject1:GetJsonText('num_invoice').
doctst.dt_data = oNestObject1:GetDate('date_invoice').
doctst.societa = oNestObject1:GetJsonText('id_ow').
doctst.tv_codice = oNestObject1:GetJsonText('currency').
wcambio = oNestObject1:GetJsonText('inv_exch_rate').
wcliente = oNestObject1:GetJsonText('id_customer').
doctst.dt_pvbrref = oNestObject1:GetJsonText('inv_pvbr_ref').
doctst.dt_dare = oNestObject1:GetJsonText('acct_code').
doctst.dt_rifcont = oNestObject1:GetJsonText('inv_title').
// doctst.dt_azione = oNestObject1:GetJsonText('action').
doctst.dt_tipodoc = 4. /* = 4 INVOICE */
doctst.dt_numero = INTEGER(documento).
doctst.dt_regiva = "F".
doctst.dt_anno = YEAR(doctst.dt_data).
doctst.dt_documento = doctst.dt_regiva +
STRING(INTEGER(doctst.dt_anno),"9999") +
STRING(INTEGER(doctst.dt_numero),"999999").
IF oNestObject1:GetJsonText('doc_wiva') = "1" THEN
doctst.dt_flagiva = TRUE.
ELSE doctst.dt_flagiva = NO.
winvtot = oNestObject1:GetJsonText('inv_total').
winvtotnoiva = oNestObject1:GetJsonText('total_no_iva').
wtotiva = oNestObject1:GetJsonText('iva_total').
/* cn_total=tot eur
cn_total_main= chf */
doctst.dt_imptot = DECIMAL(winvtot).
doctst.dt_imponibile = DECIMAL(winvtotnoiva).
doctst.dt_impiva = DECIMAL(wtotiva).
doctst.dt_cambio = DECIMAL(wcambio).
doctst.cf_codice = INTEGER(wcliente).
END.
HOW I CAN READ 'ROWS" RELATED TO 'INVOICES'? THIS IS MY QUESTION
Thx.
thanks for your replay.
MESSAGE string(ipObject:GetJsonArray('rows'):GetJsonText()) contains all key and value for rows.
How I can separate the fields:
(ex. "id_invoice_details": "24391",
"id_invoice": "12859",
"description": "Riga libera",
"total": "20.)
thx in advance.
G.
You will do the same AS for Invoices... AS Peter remarked do not use GetJsonText(). That was just so you can see the content. All you need is within the code...
You will do the same AS for Invoices... AS Peter remarked do not use GetJsonText(). That was just so you can see the content. All you need is within the code...
I cannot use this code because there is an error "no "rows" is a property'. Sorry but don't understand which is the way for save the rows of invoices. No problem for invoices but the rows missing to me some information, I can have more the one rows for invoice and more the one invoice in a Json file, Thk for help me!
oJsonArray = ResultObject:GetJsonArray("rows").
DO i = 1 TO oJsonArray:LENGTH:
oNestObject1 = OJsonArray:GetJsonObject(i).
CREATE docrig.
ASSIGN documento = oNestObject1:GetCharacter('id_invoice').
docrig.dr_testo[1] = oNestObject1:GetCharacter('description').
docrig.societa = oNestObject1:GetCharacter('id_ow').
END.
It works for me... if you use :GetJsonText() to view the content before you try to use it, you will Se if it is an array, object or property... I get the content of the rows jsonobject
Try to be more specific with naming of the jsonObjects... if you know it will be an Invoice then name it oInvoice, same for rows...oRows for Array and oRow for objects... just my way of doing :)
Hi guys,
thanks for your help. Resolved with this mode:
oJsonArray2 = oNestObject1:GetJsonArray('rows').
DO j = 1 TO oJsonArray2:LENGTH:
oNestObject2 = OJsonArray2:GetJsonObject(j).
CREATE docrig.
ASSIGN
documento = oNestObject2:GetJsonText('id_invoice')
docrig.dr_testo[1] = oNestObject2:GetJsonText('description')
docrig.societa = doctst.societa
wsequenza = oNestObject2:GetJsonText('ordering')
wqty = oNestObject2:GetJsonText('qt_accounting')
wtotal = oNestObject2:GetJsonText('total_row')
docrig.dr_avere = oNestObject2:GetJsonText('acct_code')
docrig.dr_iva = oNestObject2:GetJsonText('iva_row')
docrig.dr_regiva = doctst.dt_regiva
docrig.dr_anno = doctst.dt_anno
docrig.dr_documento = doctst.dt_documento
docrig.dr_flagiva = doctst.dt_flagiva.
END.
many thanks.
G.
Better to use i.e :GetInteger(«qt_account») if you know the datatype...
Update from Progress Community
Giancarlo Alberto Somma Hi guys,
thanks for your help. Resolved with this mode:
oJsonArray2 = oNestObject1:GetJsonArray('rows').
DO j = 1 TO oJsonArray2:LENGTH:
oNestObject2 = OJsonArray2:GetJsonObject(j).
CREATE docrig.
ASSIGN
documento = oNestObject2:GetJsonText('id_invoice')
docrig.dr_testo[1] = oNestObject2:GetJsonText('description')
docrig.societa = doctst.societa
wsequenza = oNestObject2:GetJsonText('ordering')
wqty = oNestObject2:GetJsonText('qt_accounting')
wtotal = oNestObject2:GetJsonText('total_row')
docrig.dr_avere = oNestObject2:GetJsonText('acct_code')
docrig.dr_iva = oNestObject2:GetJsonText('iva_row')
docrig.dr_regiva = doctst.dt_regiva
docrig.dr_anno = doctst.dt_anno
docrig.dr_documento = doctst.dt_documento
docrig.dr_flagiva = doctst.dt_flagiva.
END.
many thanks.
G.
You received this notification because you subscribed to the forum. To unsubscribe from only this thread, go here.
Flag this post as spam/abuse.
OK. Thx,
OK. Thx,