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



Hi Suren,

I tried your code by copy/pasting it.  The only change I made was to remove the comma after 'Smith' (as you mentioned) and it worked without error for me.  Worked perfectly, playerProfile was populated correctly.

Then, I tried removing the (E) extender for data-into, and also removed the 'allowextra=yes' and 'allowmissing=yes'.  But, it still worked without any errors.

What is needed to create the errors you're seeing?

-SK


On 6/11/2019 3:24 PM, Suren K wrote:
Hi Scott,

In my previous email i added a comma after last name ("lastName":"Smith",)
that is a issue. But even if i remove that comma after lastname (
"lastName":"Smith") and validated the JSON string using the website you
provided and again i am getting the same error.

Regards,
Surender K
+1 7022091188

On Tue, Jun 11, 2019 at 3:52 PM Suren K <suren7437@xxxxxxxxx> wrote:

Hi Scott,

Below is my program which i am getting error

D playerProfile DS Qualified
D title 5A

D firstName 25A
D lastName 25A

D Wrk_Json S 6000A
D Wrk_Opt S 200A

/Free
Wrk_Json ='{
'+
' "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",
'+
' }
'+
' }
'+
'} ';

Wrk_Opt = 'case=any doc=string ' +
'path=json/data/playerProfile ' +
'allowmissing=yes allowextra=yes ';

data-into(E) playerProfile %DATA(Wrk_Json:Wrk_Opt)
%PARSER('YAJLINTO'
:'{ "document_name": "json", +
"value_null": " " }');

/End-Free
C Eval *Inlr = *On


I am not using IFS path for storing the JSON Document, instead i am using
a variable to hold the JSON document.

Could you please let me know your comments on this one?

Regards,
Surender K
+1 7022091188

On Tue, Jun 11, 2019 at 3:27 PM Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
wrote:

Suren,

I tried your second example (the one you say "errors out"). I did not
receive an error, it worked without any problems for me. This is what I
did to try it:

1. I copy/pasted your JSON example to a file in the IFS (I used the name
'suren.json')

2. I used the following RPG code (based on yours, but changed slightly
to make it a complete program)


**free

Dcl-Ds playerProfile qualified;
title char(5);
firstName Char(25);
lastName char(25);
End-Ds;

data-into playerProfile %DATA( 'suren.json'
: 'case=convert doc=file +
path=json/data/playerProfile +
allowmissing=yes allowextra=yes')
%PARSER( 'YAJLINTO'
:'{ +
"document_name": "json", +
"value_null": " " +
}');

dsply playerProfile.title;
dsply playerProfile.firstName;
dsply playerProfile.lastName;

*inlr = *on;


What do I need to do differently to make it fail with an error?

-SK


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)


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