I have a REST-Service build with ServicStack, and in one call the user can send different types of values. Therefore, I created a property in an object of type C #.
The sent JSON looks like this:
{"name":"ffff","params":[{"pId":1,"value":[624,625]},{"pId":2,"value":"xxx"}]}
The value "value": [624,625] leads to a string object filled with "[624,625]". I was hoping to get an int-array or at least a string array, but this is a simple string. I set JsConfig.TryToParsePrimitiveTypeValues ββ= true, but this does not seem to have any effect.
I tried the latest sources from github.
Can this be done with any combination of switches, or should I make it out myself?
thanks
EDIT:
Here are some test codes:
[TestMethod] public void JsonTest() { string json = "{\"name\":\"ffff\",\"params\":[{\"pId\":1,\"value\":[624,625]},{\"pId\":2,\"value\":\"xxx\"}]}"; var x = JsonSerializer.DeserializeFromString<xy>(json); Assert.AreEqual(x.Params[0].Value.GetType(), typeof(int[])); } public class xy { public string Name { get; set; } public List<Param> Params { get; set; } } public class Param { public int PId { get; set; } public object Value { get; set; } }
source share