The following class is just an entity for registration.
> class registration
> {
> public string email
> {
> get;
> set;
> }
> public string birthday
> {
> get;
> set;
> }
> public string first_name
> {
> get;
> set;
> }
> }
There is a signup method where i am processing the values which i got from the user.I have not included full code here.just give a brief information.I will process the fields and convert one json format.I will send the json input to webapi service for further process.
class RegisterProcess { public void SignUp(registration regObj) {
JProperty UserProfile = new JProperty("RegisterProfile", new JObject( new JProperty("email", regObj.email), new JProperty("birthday", regObj.birthday), new JProperty("first_name", regObj.first_name))); } }
Some users might enter values for all fields & some of them will enter only for few fields.I want to insert only field which has a value.I want to dynamically generate JProperty UserProfile stuff.(for example:If an user enter only email&first_name,I want to create json only for those field.Null value should not be included.How to dynamically generate Json format.any ideas?
Scenario :: Registration entity - I will use for registration process as well as updateprofile process.During registration user might enter email,first_name,birthday.later he want to update only email field.He will enter data for that field alone.At that time i want to generate json rpoperty only for email field.it should not disturb[first_name and birthday] field.if i send [registration MyReg = new registration { email = "[email protected]"};],It will set [first_name and birthday field] as null.It shouldn't set null for those fields.it should retain the value which i entered while registration.i hope you got it