I write an asp.net MVC controler
I send JSON to the client as a response to an action.
{ A : "bla", B: "bla2"}
How can I make field B tentative acorrding to existance of its value
meaning:
Server object like
{ A : "bla", B: null}
will be sent as
{ A : "bla"}
This link might help http://ftp.java2s.com/Code/CSharp/Network/RemovesJsonnullobjectsfromtheserializedstringandreturnanewstringExtentionMethod.htm
Basically you serialize the c# object to a json, then you can use a regex to find all properties with null value and remove them
EDIT:
You can have an extention method on string like so