Hi All,
I call a web service to get current time info in json. Mainly did for learning purposes a while back.
The json can contain null for 2 fields (dst_until and dst_from) when NOT in DST. During DST they contain data.
When I ran into this when creating the pgm I had trouble figuring out where to use the null indicator when fetching into a DS. To get around this I just load into the DS fields.
Is there a way to fetch into the DS identifying the null indicator? NullUntil and NullFrom are defined as Int(5).
I know about using YAJL but want to understand both ways.
// Parse json Results From API Call using SQL
Dcl-ds SQLResults Qualified;
week_number Int(10);
utc_offset VarChar(100);
utc_datetime VarChar(100);
unixtime Int(10);
timezone VarChar(100);
raw_offset Int(10);
dst_until VarChar(100);
dst_offset Int(10);
dst_from VarChar(100);
dst VarChar(10);
day_of_year Int(10);
day_of_week Int(10);
datetime VarChar(100);
client_ip VarChar(100);
abbreviation VarChar(100);
End-Ds;
Exec SQL declare C1 cursor for
Select *
from JSON_TABLE(Get_CLOB_From_File('/iaccess/html/currenttime.json'),
'lax $'
Columns(week_number Integer Path '$.week_number',
utc_offset VarChar(100) Path '$.utc_offset',
utc_datetime VarChar(100) Path '$.utc_datetime',
unixtime Integer Path '$.unixtime',
timezone VarChar(100) Path '$.timezone',
raw_offset Integer Path '$.raw_offset',
dst_until VarChar(100) Path '$.dst_until'
Default ' ' On Empty
Default ' ' On Error,
dst_offset Integer Path '$.dst_offset',
dst_from VarChar(100) Path '$.dst_from'
Default ' ' On Empty
Default ' ' On Error,
dst VarChar(10) Path '$.dst',
day_of_year Integer Path '$.day_of_year',
day_of_week Integer Path '$.day_of_week',
datetime VarChar(100) Path '$.datetime',
client_ip VarChar(100) Path '$.client_ip',
abbreviation VarChar(100) Path '$.abbreviation')) x;
Exec SQL Open C1;
DoU Done;
// Exec SQL Fetch next from C1 into :SQLResults;
Exec SQL Fetch next from C1 into :SQLResults.week_number,
:SQLResults.utc_offset,
:SQLResults.utc_datetime,
:SQLResults.unixtime,
:SQLResults.timezone,
:SQLResults.raw_offset,
:SQLResults.dst_until :NullUntil,
:SQLResults.dst_offset,
:SQLResults.dst_from :NullFrom,
:SQLResults.dst,
:SQLResults.day_of_year,
:SQLResults.day_of_week,
:SQLResults.datetime,
:SQLResults.client_ip,
:SQLResults.abbreviation;
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<
http://www.walzcraft.com> Phone: 1-800-237-1326
As an Amazon Associate we earn from qualifying purchases.