Passing dictionary object as part of request to ServiceStack Swagger
I am currently working with the ServiceStack Swagger plugin and am having trouble filling in certain objects in my query, especially in vocabulary subjects.
In the following image, I want to pass a dictionary <string, string> object as JSON to FieldFilter. What is the format for this? I tried some examples, but the FieldFilter object is always deserialized as null.
UPDATE
I went through the JSON example given in this link:
http://www.newtonsoft.com/json/help/html/SerializeDictionary.htm
which shows the Dictionary <string, string> JSON representation looks like this:
{
"James": "9001",
"Jo": "3474",
"Jess": "11926"
}
but the result is still deserialized to zero. I think this is more of a limitation of ServiceStack and the Swagger plugin. I'll take on the suggestion to use a list of classes and provide another update
UPDATE 2
I tried to create a FieldFilter class (which contains two string properties). This is the JSON I am currently entering:
{
"FieldId": "1",
"Value": "Hello"
},
{
"FieldId": "2",
"Value": "Goodbye"
}
Attempting this (and other small changes) the field is still deserialized as null.
As a test, I added a field filter object to my CreateUser request, which has a single body with all the required fields. The JSON for this looks like this:
{
"FieldFilter": [
{
"FieldId": "1",
"Value": "Hello"
},
{
"FieldId": "2",
"Value": "Goodbye"
}
],
"FirstName": "",
"LastName": "",
"Password": "",
"Permissions": [
""
],
"Roles": [
""
],
"Username": ""
}
Now in this example, where all the fields are in one JSON request, the FieldFilter is deserialized with the correct values! Is there any reason why it works here? Am I missing something painfully obvious?
source to share
No one has answered this question yet
Check out similar questions: