RE: [EXTERNAL] Data-INTO with double array fails but is valid JmSON

Don Brown via RPG400-L <[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <ME3P282MB357128D05970D0EDC597DFB3E9EEA@ME3P282MB3571.AUSP282.PROD.OUTLOOK.COM>
   Yes, I did try YAJLGEN and because it is a two dimensional array it cannot
   build a data structure.

   I am now using the YAJL sub procedures which are working - just took me
   some time to work out just how to use them.

   You know the situation, many examples but none that are exactly what you
   want 😊

   Cheers
   Don

    

   Don Brown

   Senior Consultant
    
   [1]OneTeam IT Pty Ltd
   P: 1300 088 400

   -----Original Message-----
   From: RPG400-L <[email protected]> On Behalf Of Greg
   Wilburn
   Sent: Thursday, 9 October 2025 10:27 PM
   To: RPG programming on IBM i <[email protected]>
   Subject: RE: [EXTERNAL] Data-INTO with double array fails but is valid
   JSON

   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 <[email protected]> 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: [email protected]
   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 [email protected] 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: [4]https://lists.midrange.com/mailman/listinfo/rpg400-l
   or email: [email protected]
   Before posting, please take a moment to review the archives at
   [5]https://archive.midrange.com/rpg400-l.

   Please contact [email protected] for any subscription related
   questions.

   --
   Message protected by MailGuard: e-mail anti-virus, anti-spam and content
   filtering.
   [6]https://www.mailguard.com.au

   Click here to report this message as spam:
   [7]https://console.mailguard.com.au/ras/2beP2kKqjG/79ixtKPaU1MZz3a9Kpt7F/0

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://lists.midrange.com/mailman/listinfo/rpg400-l
   5. https://archive.midrange.com/rpg400-l.
   6. https://www.mailguard.com.au/
   7. https://console.mailguard.com.au/ras/2beP2kKqjG/79ixtKPaU1MZz3a9Kpt7F/0
-- 
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: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.