RE: External Returned JSON with double array

Jerry Forss <[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <BL1PPF07C40B43A4EEF1914437488F10693C6AAA@BL1PPF07C40B43A.namprd22.prod.outlook.com>
All of the elements in my are RateResponse that I have defined are loaded.
I have allowmissing and allowextra defined in the data-into.

-----Original Message-----
From: RPG400-L <[email protected]> On Behalf Of Greg Wilburn
Sent: Tuesday, December 16, 2025 9:52 AM
To: RPG programming on IBM i <[email protected]>
Subject: RE: External Returned JSON with double array

Does the error message give you a specific element of the DS?  I thought it usually showed that.

-----Original Message-----
From: RPG400-L <[email protected]> On Behalf Of Jerry Forss
Sent: Tuesday, December 16, 2025 10:30 AM
To: RPG programming on IBM i <[email protected]>
Subject: RE: External Returned JSON with double array

I am back into the office and need to get this working.
They are deprecating their old system on Friday!  Lots of notice.

Here is what I have. Notice the multi dem array on revenueDetails.
I am ignoring this part for now.

Json

{
        "order_number": "Q0355983",
        "bill_to_account_number": "52557",
        "billto": {
                "name": "WALZCRAFT INDUSTRIES INC",
                "address1": "2600 HEMSTOCK ST",
                "address2": "PO BOX 1748",
                "city": "LA CROSSE",
                "state_id": "WI",
                "zip_code": "54602"
        },
        "collection_method": "P",
        "pieces": 1,
        "weight": 292,
        "weight_um": "LB",
        "customer_name": "WALZCRAFT INDUSTRIES INC",
        "bill_distance": 82,
        "bill_distance_um": "MI",
        "freight_charge": 97,
        "otherchargetotal": 32.01,
        "total_charge": 129.01,
        "rate": 97,
        "rate_type": "F",
        "rate_unit_desc": "FLAT",
        "rate_units": 1,
        "total_spots": 1,
        "total_cubic_volume": 136080,
        "transit_days": 1,
        "freightGroupItems": [
                {
                        "description": "Container: Quote-28647-001",
                        "hazmat": false,
                        "hazmat_is_residue": false,
                        "height": 36,
                        "length": 90,
                        "width": 42,
                        "nmfc_class_code": "70",
                        "spots": 1,
                        "pieces": 1,
                        "weight": 292,
                        "weight_uom_type_code": "LBS"
                }
        ],
        "revenueDetails": [
                [
                        {
                                "name": "Fuel Surc",
                                "description": "Fuel Surcharge",
                                "calc_rate": 0.33,
                                "revenue_amount": 32.01,
                                "freight_class_code": "70",
                                "id": 68
                        },
                        {
                                "name": "Minimum B",
                                "description": "MINIMUM CHARGE",
                                "calc_rate": 97,
                                "revenue_amount": 97,
                                "freight_class_code": "70",
                                "id": 170
                        }
                ]
        ],
        "shipper": {
                "name": "WalzCraft",
                "address": "2600 Hemstock St",
                "city_name": "LA CROSSE",
                "state": "WI",
                "zip_code": "54603",
                "sched_arrive_early": "20251216080000-0600",
                "sched_arrive_late": "20251216170000-0600"
        },
        "consignee": {
                "name": "ELIAS CONSTRUCTION LLC",
                "address": "1207 FRONTAGE RD NW",
                "city_name": "BYRON",
                "state": "MN",
                "zip_code": "55920",
                "sched_arrive_early": "20251217080000-0600",
                "sched_arrive_late": "20251217170000-0600"
        },
        "notice": "Quote is only valid for the customer specified in the quote and is valid for ten (10) days.\nThe rates may increase if another customer is invoiced for the shipment.\nFuel surcharges on the final invoice will reflect the fuel surcharge in place for the customer on the ship date, regardless of the amount provided in this quote.\nThe final charge may also change if the shipment’s physical characteristics are not accurately reflected in the quote; such as being heavier, larger or belonging to a different freight class than what was provided."
}


My code


  // Rate Results From API Call
  Dcl-ds RateResponse             Qualified;

    order_number                  Char(10);
    bill_to_account_number        Char(10);
    Dcl-ds billto;
      name                        Char(50);
      address1                    Char(50);
      address2                    Char(50);
      city                        Char(50);
      state_id                    Char(20);
      zip_code                    Char(10);
    End-Ds;

    collection_method             Char(1);
    pieces                        Packed(3 : 0);
    weight                        Packed(5 : 0);
    weight_um                     Char(3);
    customer_name                 Char(50);
    bill_distance                 Packed(5 : 0);
    bill_distance_um              Char(3);
    freight_charge                Packed(7 : 2);
    otherchargetotal              Packed(7 : 2);
    total_charge                  Packed(7 : 2);
    rate                          Packed(7 : 2);
    rate_type                     Char(10);
    rate_unit_desc                Char(10);
    rate_units                    Packed(5 : 0);
    total_spots                   Packed(3 : 0);
    total_cubic_volume            Packed(7 : 0);
    transit_days                  Packed(3 : 0);

End-Ds;

I have a Monitor around this code and it fails with
Message ID . . . . . . :   RNX0356
Date sent  . . . . . . :   12/16/25      Time sent  . . . . . . :   09:19:33

Message . . . . :   The document for the DATA-INTO operation does not match
  the RPG variable; reason code 5.

There is data in RateResponse

        // Parse Response JSON Rates Doc Using YAJL
        data-into RateResponse %DATA(ResponseFile
             : 'doc=file case=any countprefix=cnt_ allowmissing=yes allowextra=yes')
             %PARSER('YAJLINTO');

From debug

EVAL RateResponse
RATERESPONSE.ORDER_NUMBER = 'Q0355983  '
RATERESPONSE.BILL_TO_ACCOUNT_NUMBER = '52557     '
RATERESPONSE.BILLTO.NAME =
         'WALZCRAFT INDUSTRIES INC                          '
RATERESPONSE.BILLTO.ADDRESS1 =
         '2600 HEMSTOCK ST                                  '
RATERESPONSE.BILLTO.ADDRESS2 =
         'PO BOX 1748                                       '
RATERESPONSE.BILLTO.CITY =
         'LA CROSSE                                         '
RATERESPONSE.BILLTO.STATE_ID = 'WI                  '
RATERESPONSE.BILLTO.ZIP_CODE = '54602     '
RATERESPONSE.COLLECTION_METHOD = 'P'
RATERESPONSE.PIECES = 001.
RATERESPONSE.WEIGHT = 00292.
RATERESPONSE.WEIGHT_UM = 'LB '
RATERESPONSE.CUSTOMER_NAME =
         'WALZCRAFT INDUSTRIES INC                          '
RATERESPONSE.BILL_DISTANCE = 00082.
RATERESPONSE.BILL_DISTANCE_UM = 'MI '
RATERESPONSE.FREIGHT_CHARGE = 00097.00
RATERESPONSE.OTHERCHARGETOTAL = 00032.01 RATERESPONSE.TOTAL_CHARGE = 00129.01 RATERESPONSE.RATE = 00097.00
RATERESPONSE.RATE_TYPE = 'F         '
RATERESPONSE.RATE_UNIT_DESC = 'FLAT      '
RATERESPONSE.RATE_UNITS = 00001.
RATERESPONSE.TOTAL_SPOTS = 001.
RATERESPONSE.TOTAL_CUBIC_VOLUME = 0136080.
RATERESPONSE.TRANSIT_DAYS = 001.

First, WHY is it giving me the RNX0356 error?  Everything in the RateResponse is there.

Second, I would like to get the accessorial info from the revenueDetails.
YAJL doesn’t like I  How best to handle.

--
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/mailman/listinfo/rpg400-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo3MjIwMjFjZmJlNWRiNTJlMjFhYzA3NDZlMzRkN2MxMDo3OjliMzA6YTNjNjRiN2Y2NTljZmNjMzdmODI2YWQ0ZTE1ZDRkMDVkNDQwYjYyOWQ4MTRjZWExMjY0YmE4YzU3ZTgzMzBmYTpwOlQ6Rg
or email: [email protected]
Before posting, please take a moment to review the archives at https://protect.checkpoint.com/v2/r01/___https://archive.midrange.com/rpg400-l___.YzJ1OnRvdGFsYml6ZnVsZmlsbG1lbnQxOmM6bzo3MjIwMjFjZmJlNWRiNTJlMjFhYzA3NDZlMzRkN2MxMDo3OmFhYmI6ZWY5ZTE3MDQzOTdlNDVlZmRhNDE3YmJjN2ExN2E5YjNkMjhjYjhkNDAzYWVjYjc4Y2ZjYWIzMmY1YTk0MDEwZjpwOlQ6Rg.

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

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: [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.

-- 
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.