SuperObject cannot handle null string

人走茶凉 提交于 2019-11-28 12:44:55

The official 1.2.4 ZIP file in the download section http://code.google.com/p/superobject/downloads/list dates from 2010, but the individual files in http://code.google.com/p/superobject/source/browse have updates up until Oct 2012.

If you go to that last URL and click on Download zip you can retrieve them.

These updated files let you use the special case null.

The code is still 'forgiving' if you omit the quotes around the string value:

{
 "bookdate": 1377554400000,
 "searchtext": a,
 "listtype": 1
}

but it now handles the special case

{
 "bookdate": 1377554400000,
 "searchtext": null,
 "listtype": 1
}

as if it was

{
 "bookdate": 1377554400000,
 "searchtext": ,
 "listtype": 1
}

or

{
 "bookdate": 1377554400000,
 "listtype": 1
}

[Do not accidentally type nil or NULL]

This release supports up until VER230 (Delphi XE2) [Note that the 'official' 1.2.4 did not even compile on more recent Delphi versions], so for later versions of Delphi you'll have to patch the compiler directives.

It also fixes the following:

  • When an floating point value happened to have an exact integer value, the JSON would have a trailing period:

    { "floatingpointvalue": 4. }

    This is now fixed:

    { "floatingpointvalue": 4 }

  • Errors in datetime conversions happening around the switch to daylight savings time in leapyears - yes, obscure.
    There was an error in the code section surrounded by {$IFDEF WINDOWSNT_COMPATIBILITY}

Note that this is still defined by default, I suggest you disable the define , e.g. with {.$IFDEF WINDOWSNT_COMPATIBILITY} [who needs to run on Windows NT nowadays?], which lets the OS handle datetime conversions:

{$ELSE}
function TzSpecificLocalTimeToSystemTime(
  lpTimeZoneInformation: PTimeZoneInformation;
  lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external 'kernel32.dll';

function SystemTimeToTzSpecificLocalTime(
  lpTimeZoneInformation: PTimeZoneInformation;
  lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external 'kernel32.dll';
{$ENDIF}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!