I want to send some part of class to server.
sending Info
[Serializable]
public class SendingInfos
{
public string tempID;
public string playerLettersInHand;
public string playerLettersMiddle;
public int playerBet;
public string playerLetterSent;
}
currently temID and playerBet has value while rest of them null.In this case, if i use
string jsondata = JsonUtility.ToJson(sendingInfos);
this and send it. Do i send the part of class which isnt null or all of it? Is there any other option to send part of it? like
string jsondata = JsonUtility.ToJson({ sendingInfos.tempID, sendingInfos.playerBet });
Edit: the reason i want to send somepart of class to server is,to keep server network traffic at low as much as possible. Also, i might do this by dividing the class to 2 class.however if there is , easier way , i want to do that.
Normal operation in this case is just to serialize the whole object. That way you make sure it can be deserialized without additional settings. NULL should be handled automatically AFAIK, so when serializing again you should get the same object back (with all values set to NULL or an actual value)
You would not normally send only half of an object, because you maintain a contract between the sender and the receiver for the full object, and not half of it or one third. That seems a bit odd and i cannot figure out why you would want this.