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



Thanks Jon

We have been getting data from outside sources more & more and sometimes we
struggle with laying out the DS & handling exceptions.


On Tue, Jan 29, 2019 at 11:33 AM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

You didn't give the full json so it took me a while but this works fo me.

Because you specified the fields as char the parser will place *null in
them.

I added the count because allowmissing is dangerous and these counts allow
any field to be missing - not just null.

dcl-s input varchar(256)
inz('{"processed_at" : "2019-01-29T13:47:58+00:00", +
"po_number" : "P347235", +
"invoice_number" : "400623985", +
"totals" : { +
"net" : "462.31", +
"tax" : null, +
"total" : "462.31", +
"carriage" : null }}');


Dcl-ds result qualified;
processed_at char(10);
po_number char(7);
invoice_number char(10);
Dcl-ds totals;
net char(10);
count_net int(5);
tax char(10);
count_tax int(5);
total char(10);
count_total int(5);
carriage char(10);
count_carriage int(5);
End-ds;
End-ds;


DATA-INTO result %data( input :
'case=any countprefix=count_ ')
%Parser( 'YAJL/YAJLINTO' );

Dsply ('PO: ' + result.po_number +
' Invoice: ' + result.invoice_number );

*InLr = *On;

Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 29, 2019, at 9:50 AM, Steve Jones <sjones@xxxxxxxxxxxxxxx> wrote:

I am returning a json object that sometimes has a field that contains
"null", tax in the example below: How can I code my program to handle
this
field when it is null? I am loading up result using data-into

processed_at "2019-01-29T13:47:58+00:00"
po_number "P347235"
invoice_number "400623985"
totals
net "462.31"
tax null
total "462.31"
carriage null
Dcl-ds result qualified dim(100);
processed_at char(10);
po_number char(7);
invoice_number char(10);
Dcl-ds totals;
tax char(10);
End-ds;














--
Steve Jones
H-P Products, Inc
330-871-2054

--
NOTE: The information in this email is confidential and may be legally
privileged. If you are not the intended recipient, you must not read,
use
or disseminate the information; please advise the sender immediately by
reply email and delete this message and any attachments without
retaining a
copy. Although this email and any attachments are believed to be free
of
any virus or other defect that may affect any computer system into which
it
is received and opened, it is the responsibility of the recipient to
ensure
that it is virus free and no responsibility is accepted by H-P Products,
Inc. for any loss or damage arising in any way from its use.
--
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
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

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