문제

Given this request DTO

public class CreateRecordRequest {
    public Dictionary<string, object> Record { get; set; }
}

when I call the service passing this JSON

{
    "Record": {
        "File": {
            "name": "DSC_3493_4_5.jpg",
            "extension": ".jpg",
            "size": 596002,
            "rawFile": {}
        },
        "Notes": "",
        "Type": ""
    }
}

File has the deserialized value "{". Since ServiceStack has no way of knowing which object File maps to, I'm curious why it doesn't deserialize it as a dictionary ("{" is inexplicable). What is the easiest way to customize deserialization of a single value like this? I'm working with Kendo's upload control and this is the JSON it submits.

도움이 되었습니까?

해결책

Because it's an object the Serializer doesn't know what type to dehydrate this into, you can force it to use a Dictionary<string,string> with:

JsConfig.ConvertObjectTypesIntoStringDictionary = true;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top