Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid class typecast for property "x" [Expected: TArray<System.string>, Actual: Array] #432

Closed
AlbertSchimidt opened this issue Oct 5, 2020 · 0 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone
Milestone

Comments

@AlbertSchimidt
Copy link

Hello again!

I've been using DMVC for a little long time now, and it works great.

But now I'm having trouble with TArray class. Like in the sample "renders" provided from the samples.zip, I can SERIALIZE an TArray<System.string> just fine, but I cannot seem to DESERIALIZE an json array. Always getting the same error "Invalid class typecast for property "x" [Expected: TArray<System.string>, Actual: Array]".

My json array is like this:

{
    "myProp": [
        "Test1",
        "Test2"
    ]
}

It's the same array generated by the Render method.

My class is like this:

TMyClass = class
private
  FMyProp: TArray<string>;
public
  property myProp: TArray<string> read FMyProp write FMyProp
end;

Trying to DESERIALIZE like this:

var
  oMyClass: TMyClass;
oMyClass := Context.Request.BodyAs<TMyClass>; // raises "Invalid class typecast for property "x" [Expected: TArray<System.string>, Actual: Array]" error

What I'm doing wrong?

@danieleteti danieleteti self-assigned this Nov 27, 2020
@danieleteti danieleteti added the accepted Issue has been accepted and inserted in a future milestone label Nov 27, 2020
@danieleteti danieleteti added this to the 3.2.1-carbon milestone Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone
Projects
None yet
Development

No branches or pull requests

2 participants