procedure TkbmMWJSONStreamer.SaveToStringBuilder builds wrong JSON

Home Forums kbmMW procedure TkbmMWJSONStreamer.SaveToStringBuilder builds wrong JSON

Viewing 1 reply thread
  • Author
    Posts
    • #55954
      VadimMest
      Participant

      Hello

      kbmMW is version 5.15.10

      procedure TkbmMWJSONStreamer.SaveToStringBuilder builds wrong JSON if DontStreamNullProperties = True and the last element is null

      The error is in next code:

      for i:=0 to n do
      begin
      co:=TkbmMWONCustomObject(o.PropertyValue[i]);
      if (co is TkbmMWONNative) and (FDontStreamNullProperties) and (TkbmMWJSONNative(co).IsNull) then
      continue;
      iStart2:=ASB.Length;
      if Pretty then
      ASB.Append(‘ ‘,(ALevel+1)*Indent);
      ASB.Append(kbmMWJSONQuoteString(o.PropertyName[i],FJQueryEscaping)+’:’);
      SaveToStringBuilder(ALevel+1,ASB,ARoot,co,AOnEachCustomObject);

      ////  Why if i<n ? All next elements can be IsNull = True and ‘,’ will be excess

      if i<n then
      ASB.Append(‘,’);
      if Pretty then
      ASB.Append(#13#10);

      ///

      DoOnObject(co,iStart2);
      end;

      In kbmMW version 5.01.00 you use to the next code:

      for i:=0 to o.PropertyCount-1 do
      begin
      co:=TkbmMWONCustomObject(o.PropertyValue[i]);
      if (co is TkbmMWONNative) and (FDontStreamNullProperties) and (TkbmMWJSONNative(co).IsNull) then
      continue;

      ////  Before te second element and before all next elements
      if b then
      ASB.Append(‘,’);
      b:=true;

      ////

      ASB.Append(kbmMWJSONQuoteString(o.PropertyName[i],FJQueryEscaping)+’:’);
      SaveToStringBuilder(ASB,ARoot,co);
      end;
      ASB.Append(‘}’);

       

      • This topic was modified 4 years, 3 months ago by VadimMest.
    • #56045
      kimbomadsen
      Keymaster

      Hi,

      Thank you for your bug report.
      It is fixed in next release.

      Kim/C4D

Viewing 1 reply thread
  • You must be logged in to reply to this topic.