RE: [EXTERNAL] Data-INTO with double array fails but is valid JSON
Greg Wilburn <gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]>
| Newsgroups | gmane.comp.lang.as400.rpg |
|---|---|
| Message-ID | <PH0PR17MB48634700B6B2723F32E3BFFBDAEEA@PH0PR17MB4863.namprd17.prod.outlook.com> |
Have you tried using the YAJLGEN command to create the data structure? Save your JSON on the IFS. Use YAJLGEN to generate the Data Structure for you (into a source member). I almost never create the DS myself (thanks Scott!). Greg -----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: 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 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 -- 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.