[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] data-into, YAJL parser issues



Scott, thank you for your reply. I did attached my progrom and the sample json file I used in the program. If you put the file on your IFS folder, change the folder name in the program. It should run. Also, I want to point out that I don't have the problem #1 when I just run my my program against a simple json string constructed within the program. I did run my json file through an online validation. It is valid. I use this website to do the validation. 
https://www.freeformatter.com/json-formatter.html 

I attach my program and json file again in case it did not go through in the first email. 

 


On Fri, Sep 20, 2019 at 6:46 PM Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:

Is this mailing list actually working, now?   It had stopped working and was not working for the past 8 month.

Dennis,

I use YAJLINTO every day, and have never run into the problems you are experiencing.  No one else besides you has reported them.  So, you must be doing something differently than the others?

Can you send me an example program (please keep it simple, it doesn't have to do anything useful, it only has to reproduce the problem.  It needs to be something I can run, considering that I don't have your files, programs, etc... so please keep it only to what is necessary.)

Without any idea how to reproduce the problems you're seeing, it's difficult to assist you.

-SK


On 9/20/2019 6:46 PM, Dennis Liu wrote:
Hi Scott, hope you are doing well! I was so excited about the new data-into from IBM and the parser YAJLINTO from YAJL. We recently applied the required PTFs to our system (7.3). I wrote a sample program to play with. But, quickly, I run into some issues:
 
1. I have to define my data structure as an array (dim(n)) even though my json string does not start with a list. I got the error: 
 "15. A call to QrnDiStartArray was made, but the matching RPG variable or subfield is not an array.". 

2. After I changed my data structure to an array, it worked. However, I run into another problem. I am missing the value for the last element from my json string. 
 
3. I also tried to retrieve an object inside the json string using 'path'. Again, I run into an error. I got the following message: 
    Pointer not set for location referenced.                              
    Application error.  MCH3601 unmonitored by QRNXUTIL at statement      
      0000000031, instruction X'0000'.                                    
    Application error.  MCH3601 unmonitored by QRNXUTIL at statement      
      0000000031, instruction X'0000'.                                    
    Unmonitored exception at statement 46500 of procedure DO_START_OBJECT
    Replacement text of message CEE9901 in QCEEMSG in QSYS not valid for  
      format specified.

Here is the snippet of my code:

       clear gJS;

       data-into gJS %data(gIFSFile
        :'doc=file case=convert allowmissing=yes allowextra=yes')
                     %parser('YAJL/YAJLINTO');


       //Retrieve part of the json string based on the path
       clear gJS2;
       data-into gJS2 %data(gIFSFile
        :'doc=file case=convert allowmissing=yes allowextra=yes +
          path=orderIsCancelled/way_points/contacts')
       %parser('YAJLINTO'
              :'{"value_null": "*none*", "document_name": "orderIsCancelled"}'); 


I also attached my program and the json string. 

Appreciate if you give me some advice. Thanks a lot. 

Warmest regards,

Dennis 
 

--
Best regards,

Dennis 刘 春

--
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi


--
Best regards,

Dennis 刘 春
{
	"id": 8498720,
	"title": "75 cases of soda to Beverage Brothers",
	"created_at": "2017-12-12T11:48:37.440Z",
	"updated_at": "2017-12-12T11:57:39.798Z",
	"customer_id": 4652688,
	"user_id": null,
	"status": 7,
	"scheduled_at": "2017-12-13T08:30:00.000Z",
	"merchant_id": 11271,
	"active_way_point_id": null,
	"extras": null,
	"webhooks": null,
	"way_points": [
		{
			"id": 10634616,
			"lat": 40.442228,
			"lng": -80.003107,
			"task_id": 8498720,
			"done": true,
			"created_at": "2017-12-12T11:48:37.409Z",
			"updated_at": "2017-12-12T11:57:39.904Z",
			"customer_id": 4652688,
			"address": "120 Fifth Ave, Pittsburgh, PA 15222, USA",
			"position": 1,
			"scheduled_at": "2017-12-13T08:30:00.000Z",
			"checkin_time": null,
			"checkout_time": null,
			"note": null,
			"find_me": null,
			"asap": null,
			"late": false,
			"eta": null,
			"etl": "2017-12-13T08:35:00.000Z",
			"silent": false,
			"phone": "+9724121234567",
			"email": "mike@xxxxxxxxxxxxxxxxxxx",
			"delete_at": null,
			"checkin_lat": null,
			"checkin_lng": null,
			"checkout_lat": null,
			"checkout_lng": null,
			"etos": 300,
			"distance_traveled_client": null,
			"distance_traveled_server": null,
			"automatically_checked_in": 0,
			"automatically_checked_out": 0,
			"merchant_id": 11271,
			"start_lat": null,
			"start_lng": null,
			"start_time": null,
			"estimated_distance": null,
			"estimated_time": null,
			"allow_editing_inventory": true,
			"must_approve_inventory": false,
			"address_second_line": "Annex B",
			"zipcode": null,
			"allow_scanning_inventory": null,
			"allow_editing_payment": null,
			"late_reason": null,
			"no_later_than": null,
			"no_earlier_than": null,
			"masked_phone_number": null,
			"twilio_number_id": null,
			"marked_late_at": null,
			"borough": null,
			"city": null,
			"distance_traveled": null,
			"state": null,
			"delivery_confirmation_scan": null,
			"delivery_confirmation_note": null,
			"delivery_confirmation_photo": null,
			"delivery_confirmation_signature": null,
			"delivery_confirmation_form": null,
			"delivery_confirmation_ocr": null,
			"company_name": null,
			"customer_contact_ids": [
				4652688
			],
			"contacts": [
				{
					"customer_id": 4652688,
					"contact_type": "phone",
					"contact_value": "+9724121234567",
					"sharing_allowed": true
				},
				{
					"customer_id": 4652688,
					"contact_type": "email",
					"contact_value": "mike@xxxxxxxxxxxxxxxxxxx",
					"sharing_allowed": true
				}
			],
			"allow_editing_original_quantity": null,
			"pickup_dropoff_option": null,
			"delivery_confirmation_cash": null,
			"district": null,
			"house_number": null,
			"street": null,
			"pending_geocode": false,
			"original_eta": null,
			"allow_automatic_set_coordinates": true,
			"has_to_leave_by": null,
			"customer": {
				"id": 4652688,
				"name": "Beverage Brothers",
				"address": "120 Fifth Ave, Pittsburgh, PA 15222, USA",
				"lat": 40.442228,
				"lng": -80.003107,
				"created_at": "2017-12-11T17:19:06.856Z",
				"updated_at": "2017-12-12T11:48:37.454Z",
				"phone": "+9724121234567",
				"merchant_id": 11271,
				"image": "/images/avatar.png",
				"access_token": "0f97d647-d1ed-4a85-b562-a730c35d6c4a",
				"confirmation_code": "7454",
				"salt": null,
				"approved": false,
				"push_token": null,
				"uuid": "0885ddb9-c943-4ef5-98f2-9db7f02e6d13",
				"email": "mike@xxxxxxxxxxxxxxxxxxx",
				"external_id": "4652688",
				"delete_at": null,
				"facebook_id": null,
				"extras": null,
				"original_lat_lng_changed": "2017-12-12T11:47:49.499Z",
				"encrypted_password": "",
				"blocked_email": false,
				"address_second_line": "Annex B",
				"zipcode": null,
				"allow_login": false,
				"stripe_id": null,
				"original_phone_number": "412-123-4567",
				"last_open_at": null,
				"last_order_at": null,
				"uploaded_profile_image": {
					"url": "/images/avatar.png"
				},
				"original_lat": 40.442228,
				"original_lng": -80.003107,
				"consecutive_checkins_out_of_geofence": 0,
				"allow_sending_email": true,
				"allow_sending_sms": true,
				"reset_password_token": null,
				"reset_password_sent_at": null,
				"mobile_version": null,
				"mobile_type": 0,
				"mobile_maker": null,
				"client_version": null,
				"client_name": null,
				"city": null,
				"borough": null,
				"state": null,
				"dev": false,
				"business_code": null,
				"language": null,
				"district": null,
				"house_number": null,
				"street": null
			},
			"full_address": "120 Fifth Ave, Pittsburgh, PA 15222, USA"
		}
	],
	"customer": {
		"id": 4652688,
		"name": "Beverage Brothers",
		"address": "120 Fifth Ave, Pittsburgh, PA 15222, USA",
		"lat": 40.442228,
		"lng": -80.003107,
		"created_at": "2017-12-11T17:19:06.856Z",
		"updated_at": "2017-12-12T11:48:37.454Z",
		"phone": "+9724121234567",
		"merchant_id": 11271,
		"image": "/images/avatar.png",
		"access_token": "0f97d647-d1ed-4a85-b562-a730c35d6c4a",
		"confirmation_code": "7454",
		"salt": null,
		"approved": false,
		"push_token": null,
		"uuid": "0885ddb9-c943-4ef5-98f2-9db7f02e6d13",
		"email": "mike@xxxxxxxxxxxxxxxxxxx",
		"external_id": "4652688",
		"delete_at": null,
		"facebook_id": null,
		"extras": null,
		"original_lat_lng_changed": "2017-12-12T11:47:49.499Z",
		"encrypted_password": "",
		"blocked_email": false,
		"address_second_line": "Annex B",
		"zipcode": null,
		"allow_login": false,
		"stripe_id": null,
		"original_phone_number": "412-123-4567",
		"last_open_at": null,
		"last_order_at": null,
		"uploaded_profile_image": {
			"url": "/images/avatar.png"
		},
		"original_lat": 40.442228,
		"original_lng": -80.003107,
		"consecutive_checkins_out_of_geofence": 0,
		"allow_sending_email": true,
		"allow_sending_sms": true,
		"reset_password_token": null,
		"reset_password_sent_at": null,
		"mobile_version": null,
		"mobile_type": 0,
		"mobile_maker": null,
		"client_version": null,
		"client_name": null,
		"city": null,
		"borough": null,
		"state": null,
		"dev": false,
		"business_code": null,
		"language": null,
		"district": null,
		"house_number": null,
		"street": null
	},
	"late": false,
	"external_id": "8498720",
	"uuid": "e20302ac-a9ac-40d6-be7b-e501863c6602",
	"priority": 8498720,
	"total_price": null,
	"price_before_tax": null,
	"delivery_price": null,
	"tip": null,
	"left_to_be_paid": null,
	"dispatcher_id": null,
	"ready_to_execute": true,
	"ended_time": "2017-12-12T11:57:39.798Z",
	"start_lat": null,
	"start_lng": null,
	"distance_traveled": null,
	"tax_price": null,
	"cancelled_at": "2017-12-12T11:57:39.794Z",
	"discount": null,
	"tip_driver_enabled": false,
	"tag_id": 8613,
	"pre_delivery_tip": null,
	"post_delivery_tip_cash": null,
	"post_delivery_tip_credit": null,
	"group_leader_id": null,
	"automatically_assigned": false,
	"run_uuid": null,
	"last_assigned_time": "2017-12-12T11:52:34.922Z",
	"task_inventories": [],
	"group_uuid": null,
	"parent_task_id": null,
	"payment_type_name": null,
	"task_notes": [
		{
			"id": 9489575,
			"note": "drop off at dock 3",
			"user_id": 59172,
			"task_id": 8498720,
			"created_at": "2017-12-12T11:48:37.421Z",
			"updated_at": "2017-12-12T11:48:37.459Z",
			"url": null,
			"way_point_id": 10634616,
			"customer_id": null,
			"pending_upload": false,
			"lat": 32.1068165,
			"lng": 34.8348318,
			"type": "TaskNote"
		}
	],
	"fleet_id": null,
	"fleet_delivery_external_id": null,
	"cancel_reason_id": 5,
	"cancel_reason": {
		"task_id": 8498720,
		"other_text": "5 cases damaged."
	},
	"reason": "Accident / technical difficulties"
}
      //---------------------------------------------------------------
      //    P R O G R A M  D E S C R I P T I O N
      //---------------------------------------------------------------
      //
      //
      //
      //---------------------------------------------------------------
      // Changes made to base version :
      //
      // Date / Author
      // 05/01/19 Dennis
      //
      //---------------------------------------------------------------

       ctl-opt DFTACTGRP(*NO) ACTGRP(*CALLER) OPTION(*SRCSTMT) BNDDIR('YAJL');

      /include yajl_h

       dcl-s gIFSFile varchar(128) inz('/home/chunl/orderIsCancelledJSON');

       dcl-ds orderIsCancelled_t qualified template;
         id int(20);
         title varchar(50);
         customer_id int(10);
         merchant_id int(10);
         dcl-ds way_points dim(10);
           id int(20);
           task_id int(10);
           address varchar(50);
           dcl-ds contacts dim(5);
             customer_id int(10);
             contact_type char(10);
             contact_value char(30);
             sharing_allowed ind;
           end-ds;
         end-ds;
         last_assigned_time char(30);
         reason varchar(50);
       end-ds;

       dcl-ds contacts_t qualified template;
         customer_id int(10);
         contact_type char(10);
         contact_value char(30);
         sharing_allowed ind;
       end-ds;

       dcl-ds gJS likeds(orderIsCancelled_t) dim(1); //why it has to be defined as array???

       dcl-ds gJS2 likeds(contacts_t) dim(10);

      //---------------------------------------------------------------
      //
      //    Main line
      //
      //---------------------------------------------------------------

       //say something

       clear gJS;

       data-into gJS %data(gIFSFile
        :'doc=file case=convert allowmissing=yes allowextra=yes')
                     %parser('YAJL/YAJLINTO');


       //Retrieve part of the json string based on the path
       clear gJS2;
       data-into gJS2 %data(gIFSFile
        :'doc=file case=convert allowmissing=yes allowextra=yes +
          path=orderIsCancelled/way_points/contacts')
       %parser('YAJLINTO'
              :'{"value_null": "*none*", "document_name": "orderIsCancelled"}');


       return;
                                                               
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi