RE: [EXTERNAL] Data-INTO with double array fails but is valid JSON
Don Brown via RPG400-L <[email protected]>
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <ME3P282MB3571DD09489DDD11FD788358E9EEA@ME3P282MB3571.AUSP282.PROD.OUTLOOK.COM> |
Thanks Greg, I would love to be proved wrong but from searching I found a thread on Scott's blog that explained that as RPG does not support multi-dimentional arrays, the JSON I have requires a 2 dimension array which is not supported. Maybe Jon or Scott will see this and confirm/deny this point. I will have a look at the data structure you provided and see if I can test it. Do really appreciate your assistance. Cheers Don Don Brown Senior Consultant [1]OneTeam IT Pty Ltd P: 1300 088 400 -----Original Message----- From: Greg Wilburn <gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]> Sent: Thursday, 9 October 2025 10:32 PM To: RPG programming on IBM i <[email protected]> Cc: Don Brown <[email protected]> Subject: RE: [EXTERNAL] Data-INTO with double array fails but is valid JSON Don, I took your example below and ran it through YAJLGEN // FIXME: // - The field lengths (varchar/packed) are guesses // and should be adjusted based on your business rules. // - The array lengths (dim keywords) are also guesses // and should be adjusted based on your business rules dcl-proc readTheJson; dcl-ds jsonDoc qualified; num_ERROR_DETAILS int(10) inz(0); ERROR_DETAILS varchar(1) dim(1); // empty; num_ERRORED_BOOKING_NUMBERS int(10) inz(0); ERRORED_BOOKING_NUMBERS varchar(8) inz('') dim(1); num_IGNORED_BOOKING_NUMBERS int(10) inz(0); IGNORED_BOOKING_NUMBERS varchar(1) dim(1); // empty; num_SAVED_BOOKING_NUMBERS int(10) inz(0); SAVED_BOOKING_NUMBERS varchar(8) inz('') dim(4); dcl-ds SUMMARY; ERROR packed(1) inz(0); IGNORED_DUPLICATE packed(1) inz(0); SAVED packed(1) inz(0); end-ds; end-ds; dcl-s ifsPathName varchar(5000); ifsPathName = '/apis/amazonsp/072/error.json'; data-into jsonDoc %DATA( ifsPathname : 'doc=file case=convert countprefix=num_') %PARSER( 'YAJLINTO' : '{ "document_name": "jsonDoc", + "number_prefix": "YAJL_" }'); end-proc; -----Original Message----- From: RPG400-L <rpg400-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org> On Behalf Of Don Brown via RPG400-L Sent: Wednesday, October 8, 2025 6:04 PM To: 'RPG programming on IBM i' <[email protected]> Cc: Don Brown <[email protected]> Subject: [EXTERNAL] Data-INTO with double array fails but is valid JSON <Reposted to the RPG List> Hi I am sure I have seen someone else with this error but searching the archives has not found the incident. The JSON has a double [[ ]] indicating two arrays. If I remove one set (leaving [ ] ) it processes correctly with the data structure below. So, we have an unnamed array inside an array, how do we build the data structure for that ? We have this JSON {"error_details":[ ["34515897: meter_off_time 2025-10-06 01:57:06+00:00 is equal to or before meter_on_time '2025-10-06 02:45:04+00:00'"] ], "errored_booking_numbers":["34515897"], "ignored_booking_numbers":[], "saved_booking_numbers":["34527032","34526927","34526855","34521442"], "summary":{"error":1,"ignored_duplicate":0,"saved":4}} I have checked and the JSON is valid. This is the data structure. We did originally have the "error_detail" in the structure but had the same problem and removed thinking it may work. dcl-ds SATSSData_rUploadData qualified template inz; dcl-ds rData likeds(DKT_GeneralReturnData); dcl-ds summary; saved zoned(5) inz(*zeros); ignored zoned(5) inz(*zeros); ignored_duplicate zoned(5) inz(*zeros); error zoned(5) inz(*zeros); end-ds summary; count_saved_booking_numbers zoned(5) inz(*zeros); saved_booking_numbers varchar(20) inz('') dim(C_SATSS_MAXDATA); count_ignored_booking_numbers zoned(5) inz(*zeros); ignored_booking_numbers varchar(20) inz('') dim(C_SATSS_MAXDATA); count_errored_booking_numbers zoned(5) inz(*zeros); errored_booking_numbers varchar(20) inz('') dim(C_SATSS_MAXDATA); end-ds; RPG Code d rtnData DS likeds(SATSSData_rUploadData) MONITOR; Data-into rtnData %Data( %trim(rData.File) : 'doc=file case=convert allowmissing=yes allowextra=yes + countprefix=count_ trim=all') %Parser( 'YAJLINTO' ); on-error; wrkMessage = 'Fail to Convert ' + %trim(rData.File); UpdateLog(wrkMessage); exsr Return; endmon; Error Message Data-Into Error message: Message ID . . . . . . : RNX0356 Date sent . . . . . . : 08/10/25 Time sent . . . . . . : 14:33:00 Message . . . . : The document for the DATA-INTO operation does not match the RPG variable; reason code 5. Cause . . . . . : While parsing a document for the DATA-INTO operation, the parser found that the document does not correspond to RPG variable "rtndata" and the options do not allow for this. The reason code is 5. The exact subfield for which the error was detected is "rtndata". The options are "doc=file case=convert allowmissing=yes allowextra=yes countprefix=count_ trim=all". The document name is /HOME/SATSS/DOWNLOAD/AIT_20251008_001644918_SATSS_UPLOADDATA.json; *N indicates that the document is not an external file. The parser is 'YAJLINTO'. *N indicates that the parser is a procedure pointer. Recovery . . . : Contact the person responsible for program maintenance to determine the cause of the problem. Technical description . . . . . . . . : Reason codes and their meanings are as follows: 1. The specified path to the name was not found in the document. 2. The document contains too few array elements for array subfields of a data structure. 3. The document contains too many array elements for array subfields of a data structure. 4. The document is missing information to match subfields. 5. The document contains extra names that do not match subfields. 6. The document contains text content within the content for the subfields of a data structure. 7. The document contains subfield items for RPG scalar fields, subfields or Any assistance appreciated. Thanks Don Brisbane - Sydney - Melbourne Don Brown Senior Consultant P: 1300 088 400 DISCLAIMER. Before opening any attachments, check them for viruses and defects. This email and its attachments may contain confidential information. If you are not the intended recipient, please do not read, distribute or copy this email or its attachments but notify sender and delete it. Any views expressed in this email are those of the individual sender -- This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options, visit: [2]https://protect.checkpoint.com/v2/r01/___https://lists.midrange.com/rfnqrfsdqnxynsktdwul955-q___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzphMzdlYzEwZDVjZDUyNzcxZTA4MjM3OTJkOTdlNjcwYTo3OmI5OTM6MTEzNTNiYjBjZjc4ODg0YmE4ZjRhZTlmMDVhZjY3MzBiZDlhMmU3MmI5MDQ4N2RmMmExZWMyMDg4MjQ0NjVjZDpwOlQ6VA or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org Before posting, please take a moment to review the archives at [3]https://protect.checkpoint.com/v2/r01/___https://archive.midrange.com/wul955-q___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzphMzdlYzEwZDVjZDUyNzcxZTA4MjM3OTJkOTdlNjcwYTo3OmI1YWM6M2YyZTg3YzZhYzNlYTFjOTZkMTZhZTc3N2QwMzM0OGU5NDA5ZWM1YmI0ZjhhZWM3YWM4ZjFhNDk3MmMxOWY2YTpwOlQ6VA. Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions. [CAUTION! This email originated outside of the organization. Please do not open attachments or click links from an unknown or suspicious origin.] Greg Wilburn Director of IT 301.895.3792 ext. 1231 -- Message protected by MailGuard: e-mail anti-virus, anti-spam and content filtering. [4]https://www.mailguard.com.au Click here to report this message as spam: [5]https://console.mailguard.com.au/ras/2beP85jfFG/7fCUQNcyCQ0JwBAsmitdkP/1 References Visible links 1. https://www.oneteamit.com.au/ 2. https://protect.checkpoint.com/v2/r01/___https://lists.midrange.com/rfnqrfsdqnxynsktdwul955-q___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzphMzdlYzEwZDVjZDUyNzcxZTA4MjM3OTJkOTdlNjcwYTo3OmI5OTM6MTEzNTNiYjBjZjc4ODg0YmE4ZjRhZTlmMDVhZjY3MzBiZDlhMmU3MmI5MDQ4N2RmMmExZWMyMDg4MjQ0NjVjZDpwOlQ6VA 3. https://protect.checkpoint.com/v2/r01/___https://archive.midrange.com/wul955-q___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzphMzdlYzEwZDVjZDUyNzcxZTA4MjM3OTJkOTdlNjcwYTo3OmI1YWM6M2YyZTg3YzZhYzNlYTFjOTZkMTZhZTc3N2QwMzM0OGU5NDA5ZWM1YmI0ZjhhZWM3YWM4ZjFhNDk3MmMxOWY2YTpwOlQ6VA. 4. https://www.mailguard.com.au/ 5. https://console.mailguard.com.au/ras/2beP85jfFG/7fCUQNcyCQ0JwBAsmitdkP/1 -- This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: [email protected] To subscribe, unsubscribe, or change list options, visit: https://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l. Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.