Created by
Stefan Glienke
| program spring_json;
{$APPTYPE CONSOLE}
uses
Spring.Serialization,
SysUtils;
const
json = '{' +
'"CustomFields": [{' +
' "Key": "website",' +
' "Value": "http://example.com"' +
'}, {' +
' "Key": "interests",' +
' "Value": "magic"' +
'}, {' +
' "Key": "interests",' +
' "Value": "romantic walks"' +
'}, {' +
' "Key": "age",' +
' "Value": "",' +
' "Clear": true' +
'}]' +
'}';
type
TCustomField = record
Key: string;
Value: string;
Clear: Boolean;
end;
TFoo = record
CustomFields: TArray<TCustomField>;
end;
var
f: TCustomField;
begin
try
f := TSerialization.JSON.Deserialize<TCustomField>(json);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
|