Im experiencing the same issue with using "skip_null". I can concur about the pattern found above. The solution provided here, replacing "skip_nulls": true with "value_null": "", will not work for me. My JSON structure has many nulls with mixed data types (string or numeric). So replacing nulls with one data type will not work in my situation.
Wed love to utilize the "skip_null", but this issue is making us to have to code work arounds. Can this be looked into and repaired?
To reiterate the bug patter: If the JSON structure has multiple objects in an array, and the first object's last element is null, then DATA-INTO crashes. Here is a simple example to demonstrate the issue. I have repeated this pattern on simple structures, like the code here,.......all the way up to very complex JSON structures.
Code: Select all
**FREE
dcl-s t_json varchar(10000) template;
dcl-ds t_structure qualified template;
first_name char(25);
last_name char(25);
end-ds;
dcl-ds t_people qualified template;
num_people int(10);
people likeds(t_structure) dim(10);
end-ds;
dcl-s json like(t_json);
dcl-ds parsed likeds(t_people);
//******************************************************************************
// This will fail: 1st Array's last element is null.
//******************************************************************************
json='{"people": [ +
{ +
"first_name":"George", +
"last_name":null +
}, +
{ +
"first_name":"John", +
"last_name":"Adams" +
} +
]}';
//******************************************************************************
// This will work: 2nd Array's last element is null.
//******************************************************************************
//json='{"people": [ +
// { +
// "first_name":"George", +
// "last_name":"Washington" +
// }, +
// { +
// "first_name":"John", +
// "last_name":null +
// } +
// ]}';
data-into parsed
%data(json:'case=any allowextra=yes allowmissing=yes countprefix=num_')
%parser('YAJL202409/YAJLINTO': '{"skip_nulls": true}');
*inlr = '1';