|
It probably isn't important but you characterized your scenario #2 as
adding another array to the document. You haven't added to an array,
you added a second object to the "data" object. It's just semantics,
but it alters the view of the JSON a bit.
I haven't worked with YAJL all that much but within the object you have
two objects, metadata and data and within the data object in your second
scenario, you have two objects, playerPin and playerProfile. I would
guess that adding a second object shouldn't affect the prior reference:
Scenario 1
data.playerProfile
Scenario 2
data.playerPin
data.playerProfile
Maybe giving us the error message would help us track down the solution....
Pete Helgren
www.petesworkshop.com
GIAC Secure Software Programmer-Java
Twitter - Sys_i_Geek IBM_i_Geek
Pete Helgren
www.petesworkshop.com
GIAC Secure Software Programmer-Java
Twitter - Sys_i_Geek IBM_i_Geek
On 6/10/2019 9:16 PM, Suren K wrote:
Hi Everyone,Document. I
I am using the Scott Klement's YAJL parser for Parsing the JSON
am receiving an error when i parsing a document. Let me explain it in two"json",
scenario, Scenario 1 (I can Parse the JSON Document) and Scenario 2 (I
cannot Parse the JSON Document which i am receiving an Error)
Scenario 1: (Parsed Successfully)
JSON Document:
{
"metadata":{
"propertyId":"E4",
"suren":"suren",
"clientId":"ATRIENTKIOSK",
"transDateTime":"2017-11-30T18:25:08Z",
"transStation":"DEVICE1",
"transEmployee":"MASTR"
},
"data":{
"playerProfile":{
"title":"Mr",
"firstName":"John",
"lastName":"Smith"
}
}
}
Data Structure:
Dcl-Ds playerProfile qualified;
title char(5);
firstName Char(25);
lastName char(25);
End-Ds;
RPG Code for Parsing this document
data-into(E) playerProfile %DATA(Wrk_Json: case=convert doc=string
path=json/data/playerProfile allowmissing=yes allowextra=yes)
%PARSER('YAJLINTO' :'{ "document_name":
"value_null": " " }');--
This one works fine.
Scenario 2: (Unable to Parse, got an Error while Parsing)
Add one more array in the document and trying to parse the same
playerProfile i am getting error. Sample as below
JSON Document:
{
"metadata":{
"propertyId":"E4",
"suren":"suren",
"clientId":"ATRIENTKIOSK",
"transDateTime":"2017-11-30T18:25:08Z",
"transStation":"DEVICE1",
"transEmployee":"MASTR"
},
"data":{
"playerPin":{
"pinNumber":"7924"
},
"playerProfile":{
"title":"Mr",
"firstName":"John",
"lastName":"Smith"
}
}
}
Data Structure:
Dcl-Ds playerProfile qualified;
title char(5);
firstName Char(25);
lastName char(25);
End-Ds;
RPG Code for Parsing this document
data-into(E) playerProfile %DATA(Wrk_Json: case=convert doc=string
path=json/data/playerProfile allowmissing=yes allowextra=yes)
%PARSER('YAJLINTO' :'{ "document_name":
"json", "value_null": " " }');
This Scenario Errored Out.
Could you please someone let me know whether this scenario is not handled
in YAJL Parser or am i doing something wrong?
Regards,
Surender K
This is the RPG programming on IBM i (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
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.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.