-
-
Notifications
You must be signed in to change notification settings - Fork 375
Closed
Labels
acceptedIssue has been accepted and inserted in a future milestoneIssue has been accepted and inserted in a future milestone
Milestone
Description
Hi, Daniele,
If you try to deserialize JSON like this:
"jsonrpc": "2.0",
"id": 14,
"result": [
{
"id": 155,
"added": "2011-08-05T17:48:41.000+04:00",
"name": "Jhon",
"expirationDate": "2021-12-31",
"maxUpdateDate": null,
"appVersion": null,
"activated": null
}]
into
TCustomer = record
Id: NullableInt32;
Added: TDateTime;
Name: NullableString;
ExpirationDate: NullableTDate;
MaxUpdateDate: NullableTDate;
AppVersion: NullableString;
Activated: NullableTDateTime;
end;
you will get an exception: Project raised exception class EJsonCastException with message 'Cannot cast Integer into Object'.
Solution: modify function TMVCJsonDataObjectsSerializer.JSONObjectToRecord in MVCFramework.Serializer.JsonDataObjects.pas.
Before:
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lRTTIType);
if lField.FieldType.IsRecord then
begin
JSONObjectToNestedRecordField(JSONObject.O[lKeyName], lField, 0, lBuffer);
end
after
lKeyName := TMVCSerializerHelper.GetKeyName(lField, lRTTIType);
if lField.FieldType.IsRecord and not lField.FieldType.Handle.NameFld.ToString.StartsWith('Nullable') then
begin
JSONObjectToNestedRecordField(JSONObject.O[lKeyName], lField, 0, lBuffer);
end
Metadata
Metadata
Assignees
Labels
acceptedIssue has been accepted and inserted in a future milestoneIssue has been accepted and inserted in a future milestone