I want to do a JSON get request on a REST API.
When I post a resource and use a get immediately after that I get a JSON object in my response.
When I put the resource after I post and use a get after that then the JSON object changes into an array.
Here are some example responses I get:
After post and put :
{
"metadata":{
"entry":[
{
"@key":"x",
"$":"y"
},
{
"@key":"x",
"$":"y"
}
]
}
}
After only post :
{
"metadata": {
"entry": {
"@key": "cachingEnabled",
"$": "false"
}
},
}
I can get it both working using the either of the following code.
JSON array :
public class MetaData
{
[JsonProperty("entry")]
public List<EntryType> Entry { get; set; }
}
JSON object :
public class MetaData
{
[JsonProperty("entry")]
public EntryType Entry { get; set; }
}
How can I map this in c# to one property ?