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



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,

I am using the Scott Klement's YAJL parser for Parsing the JSON Document. I
am receiving an error when i parsing a document. Let me explain it in two
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": "json",
"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

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.