0

I have a very simple ServiceStack service which I am invoking it via JSONServiceClient and c# typed API.

However, when I have empty arguments in Request params, ServiceStack is deserializing this into null values. I have looked and it seems like in JSV it is by design but JSON should retain non null values as they are. I have now also set following two settings in Global.asax.cs but with no improvement:

JsConfig.IncludeNullValues = true;
JsConfig.ThrowOnDeserializationError = true;

I'm using ServiceStack version 3.9.69 and IIS version 8.0.

Scott
  • 21,211
  • 8
  • 65
  • 72
user179400
  • 97
  • 7

1 Answers1

0

Do you need to differentiate between Null and Empty Strings? If not, then treat them as the same thing, you can check for them using string.IsNullOrEmpty(string str)

From a quick Google of the issue, it seems as a known problem, so you are going to need to work around it. Perhaps before serializing the, configure null values to a string "NULL"?

Talon
  • 3,466
  • 3
  • 32
  • 47
  • 1
    Thanks Talon. I thought of that, but the semantics of null and empty is different and treating them as same I may run into issues in future. I can solve the problem using checking for null or empty both and treat them same way but as I said they are essentially different things. Would you share the link where you find in context of JSON , I did find that in context of JSV but not JSON. – user179400 Feb 02 '14 at 22:30