Default values for the JSON serializer


(Sindre) #1

Currently the JSON serializer will raise an exception if a complex structure from the client operation call is missing an element of type int, int64, decimal, double, datetime, enums and guids. I can’t see any reason why those are just assigned default values. Strings, complex, etc. types are handled gracefully.

This will help a lot as we then can add fields on complex types in parameters to operation, without breaking compatibility with clients. It very difficult to keep all different clients in sync with the server API, and I don’t see any problem with default values as long as the developer are aware that new fields will be initialized with default values and maintains functional behaviour with that in mind.

I intend to try this out by creating an new JSON message (TRoJSONMessage/TROJsonSerializer pair), and just override the affected TROJsonSerializer.ReadXXXXXX methods by traping the exception and returning appropriate default values.

Any thoughts on this?

PS! I know there is something coming on versioning in the next release, but I think this will solve most of our challenges.

Sindre


(EvgenyK) #2

this will work.
I’ll log issues for implementing this feature


(RemObjects) #3

Thanks, logged as bugs://81447


(RemObjects) #4

Thanks, logged as bugs://81448


(RemObjects) #5

Thanks, logged as bugs://81449


(RemObjects) #6

bugs://81447 got closed with status fixed.