|
Your json string is not valid.
Find a json validator and check your string. (Notepad++ has a plugin,
SoapUI or try this link https://jsonlint.com/
I changed you json to the following and then it validated but I am not
sure if you wanted an array for data ?
{
"Code": 400,
"Message": "Error",
"Data": "ConsigneeAddress.Zip Validation failed for property. "
}
Don Brown
"RPG400-L"<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> wrote on 01/02/2019
07:31:26 AM:
From: "mlazarus"<mlazarus@xxxxxxxxxxxx>exact
To: "RPG programming on the IBM i (AS/400 and iSeries)"<rpg400-
l@xxxxxxxxxxxx>
Date: 01/02/2019 07:32 AM
Subject: DATA-INTO error using YAJLINTO
Sent by: "RPG400-L"<rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>
I'm trying to use DATA-INTO using YAJLINTO. It's based on one of
Scott's examples.
(https://www.common.org/scotts-iland-blog/parsing-json-data-into/).
This is the test code:
dcl-s json varchar(5000) Inz(
'{"Code":400,"Message":"Error","Data":["ConsigneeAddress.Zip -+
Validation failed for property."]' ) ;
dcl-s Msg varchar( 47 ) ;
dcl-s x int( 10 );
dcl-ds MyData qualified;
Code varchar( 5 ) ;
Message varchar( 50 ) ;
num_Data int( 10 ) ;
dcl-ds Data dim( 50 ) ;
*N char( 50 ) ;
end-ds;
end-ds;
data-into MyData %DATA( json: 'case=any countprefix=num_ +
allowextra=yes' )
%PARSER( 'YAJLINTO' );
Msg = MyData.Message ;
dsply ( 'Code: ' + MyData.Code ) ;
dsply ( 'Msg: ' + Msg ) ;
dsply ( 'Num: ' + %EditC( MyData.num_Data:'1' ) ) ;
for x = 1 to MyData.num_Data ;
dsply MyData.Data( x ) ;
endfor;
*INLR = *On ;
___________
If I have allowextra=yes I receive RNX0356 The document for the
DATA-INTO operation does not match the RPG variable; reason code 15.
Cause . . . . . : While parsing a document for the DATA-INTO
operation, the
parser found that the document does not correspond to RPG variable
"mydata"
and the options do not allow for this. The reason code is 15. The
subfield for which the error was detected is "mydata". The optionsare
"case=any countprefix=num_ allowextra=yes". The document name is *N;*N
indicates that the document is not an external file. The parser is
'YAJLINTO'. *N indicates that the parser is a procedure pointer.
Reason code 15: A call to QrnDiStartArray was made, but the matching RPG
variable orquestions.
subfield is not an array.
___________
Without allowextra=yes it points to reason code 5, which is:
The document contains extra names that do not match subfields.
___________
Is this because the Data array is not named? If yes, is there a way
around this?
-mark
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxx for any subscription related
Help support midrange.com by shopping at amazon.com with our affiliatelink:
https://amazon.midrange.comservice.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
As an Amazon Associate we earn from qualifying purchases.
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.