× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Scott,

Thank you, I will give it a try ....

And yes I am actually using (trying) it today for the first time....I didn't realize I needed another DS wrapped around the others ...

Thanks a million ..


Mit freundlichen Grüßen / Kind regards / Bien à vous,

Seán



-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Tuesday, 30 May 2023 19:32
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Issue with YAJL

Hi Sean,

You have "allowextra=yes", which means that the JSON document can have elements that aren't in your data structure. However, it must also have a field for each one that is in your JSON document.

Your document is structured like this:

{ "data": [{ ...fields... "mocrm_positionen": [{ ...fields...}] }] }

That means the very first thing it will look for is a subfield named "data" inside your data structure. However, your data structure does not have that.

Furthermore, your structure has a field named "count_hdr", but there is no "count_hdr" in the JSON document.

Also, "mocrm_positionen" is defined in your program with DIM(50), but the JSON document does not contain 50 array elements.

So all 3 of these things will result in the error you describe. I'm guessing you've never worked with JSON or DATA-INTO before? The document has to match the data structure.


Consider making your DS look like this:

(Notice that "data" is now a subfield of the data structure called "json". The "data" and "mocrm_positionen" fields are preceded by a field prefixed with "num_" that will be used to count the number of each, so the the size of the array in the JSON doesn't have to match the size of the array in your RPG. This also means you must now change your data-into statement to go into the "json" data structure, and use the "countprefix" option.)

dcl-dsjson qualified;
num_data int(10);
dcl-dsdata dim(50);
akt_id char(36);
adr_id char(36);
per_id char(36);
usr_id char(36);
prj_id char(36);
url_id char(36);
adl_id char(36);
akt_datum char(19);
akt_bis char(19);
akt_typ char(10);
akt_ordtyp char(1);
akt_deltyp char(2);
akt_kurztext char(50);
akt_freitext char(100);
akt_status char(1);
akt_kndbelnr char(50);
akt_rechnr char(20);
akt_lieferdatum char(10);
akt_bbemerk char(1);
akt_belegnr char(10);
adr_firma char(2);
adr_debitor char(10);
adr_pl char(3);
adr_vertreternr char(3);
akt_rabatt char(10);
akt_sum char(15);
adr_freitext char(256);
rowflag char(1);
//
num_mocrm_positionen int(10);
dcl-dsmocrm_positionen Dim(50);
pos_id char(36);
akt_id char(36);
art_id char(20);
art_pl char(6);
art_ean1 char(13);
art_ean2 char(13);
pos_freitext char(100);
pos_menge char(10);
pos_lmenge char(15);
pos_preis char(15);
pos_rabatt char(15);
pos_kst char(10);
art_waehrung char(3);
akt_lieferdatum char(10);
art_matrix char(20);
pos_order char(10);
rowflag char(1);
end-dsmocrm_positionen;
//
end-dsdata;
end-dsjson;
...and...

evaloptions='doc=file case=convert allowextra=yes countprefix=num_'; DATA-INTOjson %Data(%trim(jsonData):
%trim(options))
%Parser('YAJL/YAJLINTO')
FWIW, I also wouldn't recommend hard-coding the "YAJL" library, but instead would add it to the library list. There may be a time when you want to test a different version of YAJL, so having it in your library list means you can use a different version of YAJL in a different library simply by changing the library list.

Good luck!


On 5/30/23 11:51 AM, Sean Courtney wrote:
Hi,

Sorry about that ..

Here my code : I have excluded some values as I do not need them :
allowextra=yes

dcl-ds data dim(50) Qualified;
akt_id char(36);
adr_id char(36);
per_id char(36);
usr_id char(36);
prj_id char(36);
url_id char(36);
adl_id char(36);
akt_datum char(19);
akt_bis char(19);
akt_typ char(10);
akt_ordtyp char(1);
akt_deltyp char(2);
akt_kurztext char(50);
akt_freitext char(100);
akt_status char(1);
akt_kndbelnr char(50);
akt_rechnr char(20);
akt_lieferdatum char(10);
akt_bbemerk char(1);
akt_belegnr char(10);
adr_firma char(2);
adr_debitor char(10);
adr_pl char(3);
adr_vertreternr char(3);
akt_rabatt char(10);
akt_sum char(15);
adr_freitext char(256);
rowflag char(1);
count_hdr int(5);

//
dcl-ds mocrm_positionen Dim(50);
pos_id char(36);
akt_id char(36);
art_id char(20);
art_pl char(6);
art_ean1 char(13);
art_ean2 char(13);
pos_freitext char(100);
pos_menge char(10);
pos_lmenge char(15);
pos_preis char(15);
pos_rabatt char(15);
pos_kst char(10);
art_waehrung char(3);
akt_lieferdatum char(10);
art_matrix char(20);
pos_order char(10);
rowflag char(1);

end-ds mocrm_positionen;
//
end-ds data;

Here the complete JSON

{
"data": [
{
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"adr_id": "d3e0e5eb-d0bd-71f3-b943-459215394630",
"per_id": null,
"usr_id": "cafecafe-cafe-cafe-cafe-0123456789ab",
"prj_id": null,
"url_id": null,
"adl_id": null,
"akt_datum": "2023-05-25 11:18:03",
"akt_bis": "2023-05-25 13:18:03",
"wvl_datum": "2023-05-25 09:27:30",
"akt_typ": "auf",
"akt_ordtyp": "0",
"akt_deltyp": "01",
"akt_kurztext": "127874\/auf",
"akt_freitext": null,
"akt_nextstep": null,
"akt_status": "A",
"akt_richtung": "T",
"akt_prio": "4",
"akt_kndbelnr": null,
"akt_rechnr": null,
"akt_sign1": null,
"akt_signname1": null,
"akt_sign2": null,
"akt_signname2": null,
"akt_email": null,
"akt_fax": null,
"akt_tel": null,
"akt_url": null,
"akt_kopie_fax": "0",
"akt_kopie_mail": "0",
"akt_kopie_post": "0",
"akt_lieferdatum": "2023-06-01",
"akt_igrund": "0",
"akt_bgrund": "0",
"akt_btodo": "0",
"akt_bbemerk": "0",
"akt_ursprung": "0",
"akt_belegnr": "0",
"adr_firma": "04",
"adr_debitor": "127874",
"adl_num": "0",
"adr_name1": "& SOON Development",
"adr_name2": "To attention of Satoshi OTSUKI",
"adr_name3": null,
"adr_strasse": "19, rue du General Gallieni",
"adr_hn": null,
"adr_land": "FR",
"adr_zip": "78220",
"adr_ort": "Viroflay",
"adr_lbed": "0",
"adr_zbed": "10 Tage 2%",
"adr_pl": "EBR",
"adr_ustid": null,
"adr_stnr": null,
"adr_stkz": "1",
"adr_kategorie": "0",
"adr_abc": "C",
"akt_showpreis": "1",
"adr_rabattgruppe": null,
"adr_listpruefung": "0",
"adr_vertreternr": "200",
"akt_doubletten": "0",
"akt_rabatt": "0.00",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"akt_calident": null,
"akt_img_blob": null,
"akt_sum": "407.70",
"akt_uebernachtung": "0",
"akt_dauer_h": "0.25",
"akt_tbrkmvon": "0",
"akt_tbrkmbis": "0",
"akt_tbrkmpriv": "0",
"akt_tbrspvon": "08:00:00",
"akt_tbrspbis": "16:00:00",
"tbr_tagesart": "1",
"akt_tbrazvon": "08:00:00",
"akt_tbrazbis": "16:00:00",
"akt_fruehstueck": "0",
"wez_group": "default",
"akt_blob": null,
"adr_longitude": null,
"adr_latitude": null,
"adr_freitext": null,
"adr_wvldatum": null,
"jsblob": null,
"lft": "0",
"rgt": "0",
"loginfo": null,
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:18:03",
"uusr": "e6754fd0-251d-425d-9aa5-452519577999",
"udt": "2023-05-30 11:42:35",
"rowflag": "N",
"mocrm_positionen": [
{
"pos_id": "0b8f052c-410f-4073-9af0-3200e0b672c2",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3180U-53-DG",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567170260",
"art_ean2": "888989030801",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2019-07-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "60.90",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3180U-53-DG",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "3",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:39",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:39",
"rowflag": "N"
},
{
"pos_id": "14d24773-a7c6-455c-843a-3df23087851c",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3162U-54-BL",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567383844",
"art_ean2": "888989240101",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2039-01-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "75.00",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3162U-54-BL",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "0",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:34",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:34",
"rowflag": "N"
},
{
"pos_id": "52c80d05-ca0d-442d-a68c-07d98cad6a5e",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3162U-54-DG",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567049153",
"art_ean2": "883475867008",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2039-01-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "75.00",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3162U-54-DG",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "2",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:36",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:36",
"rowflag": "N"
},
{
"pos_id": "562e136e-0182-41f1-9e58-e91a36c71822",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3180U-53-NV",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567170284",
"art_ean2": "888989030825",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2019-07-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "60.90",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3180U-53-NV",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "5",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:41",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:41",
"rowflag": "N"
},
{
"pos_id": "773ff826-bb00-4765-a3aa-c4444f33688c",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3180U-53-GR",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567170277",
"art_ean2": "888989030818",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2019-07-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "60.90",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3180U-53-GR",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "4",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:40",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:40",
"rowflag": "N"
},
{
"pos_id": "8c1ef955-3ccb-4fb0-88b0-e9bee0be592d",
"akt_id": "226f24ca-3e72-4ac4-be7b-0a2905743e89",
"art_id": "AB3162U-54-BR",
"art_pl": "0",
"art_name1": "AD LIB",
"art_name2": null,
"art_ean1": "4549567049146",
"art_ean2": "883475866995",
"pos_freitext": "AD LIB Herren Brille",
"art_mwst": "19.00",
"art_einh": "St",
"art_faktor": "0",
"art_bestandlager": "0",
"art_ausldatum": "2039-01-01",
"pos_menge": "1.00",
"pos_menge_ret": "0.000",
"pos_menge_ret_mhd": "0.00",
"pos_menge_ret_defekt": "0.00",
"pos_menge_ret_abwesend": "0.00",
"pos_grund_auf": null,
"pos_grund_ret": null,
"pos_lmenge": "0.000",
"pos_preis": "75.00",
"pos_rabatt": "0.00",
"pos_kst": "1000",
"art_warengruppe": "Fassungen",
"akt_kndbelnr": null,
"ser_id": null,
"art_ve": "1.000",
"art_waehrung": "EUR",
"pos_var1": "0",
"pos_var2": "0",
"pos_var3": "0",
"pos_preisaenderbar": "0",
"pos_dis_grund": "0",
"akt_lieferdatum": "2023-06-01",
"art_matrix": "AB3162U-54-BR",
"art_manuell_preis": "0",
"art_rabattgruppe": "04AD LIB",
"pos_naturalrabatt_menge": "0.00",
"pos_naturalrabatt_connected": "1",
"pos_order": "1",
"iusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"idt": "2023-05-25 11:30:35",
"uusr": "cafecafe-cafe-cafe-cafe-0123456789ab",
"udt": "2023-05-25 11:30:35",
"rowflag": "N"
}
]
}
]
}

Mit freundlichen Grüßen / Kind regards / Bien à vous,

Seán


-----Original Message-----
From: RPG400-L<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jon
Paris
Sent: Tuesday, 30 May 2023 18:46
To: RPG programming on IBM i<rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Issue with YAJL

1) You haven't given us much of the json which makes it difficvult to
guess

2) You say the problem arises at uusr but that doesn't appear in the DS at all. Is that the purpose of allowextra?

3) Are the elements at which it errors in the inner structure? If so, since you have no count for the array (i.e. no countprefix is specified) and no allowmissing option so I would expect an error if there were less that 50 elements in the inner array.

Beyond that guess we need to know more.


Jon P.

On May 30, 2023, at 11:13 AM, Sean Courtney<scourtney@xxxxxxxxxxx> wrote:

Hello all,



I am having a strange encounter with YAJL ….



The naming on my DS matches the JSON exactly and parsing seems to
work partially ….



I have 1 header and multiple lines ….



The header is processed and some of the lines but then in the middle
it just stops with an error : The document for the DATA-INTO
operation does not match the RPG variable



I am using QIBM_RPG_DATA_INTO_TRACE_PARSER to view what is being
processed and I can locate where the parser stops …but I have no idea
why …



[code]

dcl-s jsonData Varchar(100) Inz('/tmp/test.json');



dcl-ds data dim(50) Qualified;

akt_id char(36);

adr_id char(36);

per_id char(36);

usr_id char(36);

prj_id char(36);

url_id char(36);

.

.

.

dcl-ds mocrm_positionen Dim(50);

pos_id char(36);

akt_id char(36);

art_id char(20);

art_pl char(6);

art_ean1 char(13);

.

.

end-ds data;

end-ds mocrm_positionen;



eval options = 'doc=file case=convert allowextra=yes';



DATA-INTO data %Data(%trim(jsonData):

%trim(options))

%Parser('YAJL/YAJLINTO');



[code]



The parser stops at udt for no apparent reason …



The values when it stops are ..



"uusr": "e6754fd0-251d-425d-9aa5-452519577999",

"udt": "2023-05-26 11:03:16",



Any help would be greatly appreciated…



Mit freundlichen Grüßen / Kind regards / Bien à vous,



Seán



--
This is the RPG programming on IBM i (RPG400-L) mailing list To post
a message email:RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
or email:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.

Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email:RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit:https://lists.midrange.com/mailman/listinfo/rpg400-l
or email:RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives athttps://archive.midrange.com/rpg400-l.

Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.


--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.