sitemule / noxDB

Not only XML. SQL,JSON and XML made easy for IBM i
MIT License
41 stars 20 forks source link

data-into issue: A call to QrnDiEndStruct or QrnDiEndArray was not expected. #69

Closed Helaas closed 1 year ago

Helaas commented 2 years ago

Hello,

I'm here to make some trouble again 🙂

We've noticed that an empty string can cause the data-into parser to crash:

dcl-ds params qualified inz;
  s  char(10)           inz;
  a likeds(a_t) inz(*likeds);
end-ds;

dcl-ds a_t qualified template;
  o likeds(o_t) dim(99) inz(*likeds);
end-ds;

dcl-ds o_t qualified template;
  b char(100) inz;
  c char(100) inz;
end-ds;

dcl-s pfrom pointer;

//--------------------------------------------------------------------
pFrom = json_parseString ('{    -
   "s":"Life is a gift",        -
   "a":{                        -
      "o":[                     -
         {                      -
            "b":"hello world",  -
            "c":" "             -
         },                     -
         {                      -
            "b":"hello world",  -
            "c":" "             -
         },                     -
         {                      -
            "b":"hello world",  -
            "c":" "             -
         }                      -
      ]                         -
   }                            -
}');

// works fine
data-into params %data ('':'allowextra=yes allowmissing=yes case=any')
                 %parser(json_DataInto(pFrom));
json_delete(pFrom);

pFrom = json_parseString ('{    -
   "s":"Life is a gift",        -
   "a":{                        -
      "o":[                     -
         {                      -
            "b":"hello world",  -
            "c":""              -
         },                     -
         {                      -
            "b":"hello world",  -
            "c":""              -
         },                     -
         {                      -
            "b":"hello world",  -
            "c":""              -
         }                      -
      ]                         -
   }                            -
}');

// crash!
data-into params %data ('':'allowextra=yes allowmissing=yes case=any')
                 %parser(json_DataInto(pFrom));
json_delete(pFrom);

Return;         

In summary, for the string where c has a space between the quotes there is no issue. ( "c":" ") However, for "c":"" we run into the issue.

Strdbg error Joblog Joblog detail Joblog detail2

NielsLiisberg commented 2 years ago

Thanx !! I can confirm it - we can reproduce the issue here. Fix is on its way !!