Deserialize array without a name?

i have data coming down that looks like this:

[
{
“direction”: “UPLOAD”,
“rate”: “0”,
“fileName”: “FOR508-USB[FOR 508-508.17.6A].iso”,
“fileSize”: 38428246016,
“member”: “eric.zimmerman@foo.com”,
“timeElapsed”: “22215”,
“protocol”: “mxwan”,
“userAgent”: “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36”
}
]

when nothing is present, i get back

there can, of course, be more than one item. The json looks valid and i tested it via jsonlint too.

I have a class that represents the DTO for the items in the array, but how do i tell SS to make a list from the json since there is no name?

i tried a datacontract and dataname attribute with name=“” but no go. as it stands now its complaining when deserializing:

Type definitions should start with a ‘{’, expecting serialized type ‘CurrentTransferResponse’, got string starting with:

The Request DTO needs to match the payload that’s sent which since it’s an Array your Request DTO should inherit a List<T>, e.g:

public class MyRequest : List<CurrentTransfer> {}

public class CurrentTransfer 
{
    public string Direction { get; set; }
    //etc
}
1 Like

That did it!

Thanks!

1 Like