You are not logged in.
Pages: 1
Is it correct that while decoding a string field that contains NULL in JSON, decoding must be interrupted? Probably it would be correct to continue decoding?
Type
TLinkItem = class(TCollectionItem)
private
Fid : integer;
Fanchor : String;
Furl : String;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property Anchor : String read Fanchor write Fanchor;
property Id : integer read Fid write Fid;
property Url : String read Furl write Furl;
end;
Type
TLinkItems = Class(TCollection)
private
function GetItem(index: integer): TLinkItem;
procedure SetItem(index: integer; value : TLinkItem);
public
constructor Create;
function Add(_Fid : integer; _Fanchor : String; _Furl : String): TLinkItem;
property Items[index: integer]: TLinkItem read GetItem write SetItem; default;
end;
JSON:
[
{
id: 107309,
url: null,
anchor: ""
},
{
id: 107312,
url: "http://www.google.com",
anchor: "google"
}
]
Offline
Is not 'null' reserved for objects, in JSON?
In fact, there is no "type expectation" in JSON itself, but if you expect a string field to be a string, you expect "" and not null.
In Delphi, there is no nullable string, as it does exist with C# or Java.
I suspect it should be reflected in JSON also:
[
{
id: 107309,
url: "",
anchor: ""
},
{
id: 107312,
url: "http://www.google.com",
anchor: "google"
}
]
But we can change this behavior to let the JSONToObject() method be less rigid about its expectations.
Offline
Pages: 1