× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Nevermind..... I figured out the problem (and it was me).....

Jim Bostwick

From: Jim L. Bostwick
Sent: Thursday, May 31, 2018 7:50 AM
To: 'rpg400-l@xxxxxxxxxxxx' <rpg400-l@xxxxxxxxxxxx>
Subject: YAJLINTO error

I am processing a JSON document using YAJLINTO but the data structure is not being populated. JSONFile is the IFS file I am processing, which looks like this:

{"InboundMessagesResult":{"ErrorCode":1000,"Message":"Invalid security token"}}


Dcl-Ds Results Qualified Inz;
numMessagesSentResult Int(10);
Dcl-Ds MessagesSentResult;
Result Ind;
ErrorCode Zoned(5:0);
Message VarChar(300);
Dcl-Ds Response LikeDs(Response_T) Dim(9999);
numResponse Int(10);
End-Ds;
End-Ds;

options = 'doc=file allowextra=yes countprefix=num case=any ';

Monitor;
Data-Into Results %Data(%Trim(JSONFile): %Trim(options))
%Parser('YAJL/YAJLINTO':
'{"value_true": "1", +
"value_false": "0", +
"value_null": " "}');
On-Error;
SyDsMsg.MsgDta = 'Error parsing ' + %TrimR(JSONFile);
Error = *On;
EndMon;

Normally, there is an array of results returned, but if there are errors only a portion of the expected JSON is returned. I have set the QIBM_RPG_DATA_INTO_TRACE_PARSER environment variable so that I can see what the parser is doing.

The trace looks like this:

---------------- Start ---------------
Data length 158 bytes
Data CCSID 13488
Converting data to UTF-8
Allocating YAJL stream parser
Parsing JSON data (yajl_parse)
No name provided for struct, assuming name of RPG variable
StartStruct
ReportName: 'InboundMessagesResult'
StartStruct
ReportName: 'ErrorCode'
ReportValue: '1000'
ReportName: 'Message'
ReportValue: 'Invalid security token'
EndStruct
EndStruct
YAJL parser status 0 after 79 bytes
YAJL parser final status: 0
---------------- Finish --------------

Not sure what I am doing wrong. The code makes it through the Monitor block OK but I was expecting that the Results.MessagesSentResult.Result indicator would be set, and that the
Results.MessagesSentResult.Message field would have data in it, however none of the parsed data is there.

Jim Bostwick


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.