Json always instantiation the objects?


I am making my first aplication with unity. I am using JSON to communicate to a rest server. All go fine, but i seeing that the desserialization always create the objects, including the info that arrive null from server.

This is my master return of the server where the others extend:

public class RetornoServer{
    public string mensajeError;
	public string mensajeInformativo;
	public ObjetoSesion objetoSesion;
	**public ErrorJson errorJson;**
	public string entorno;

ErrorJson only have info when server have an error and put the info there. In other cases, ErrorJson go empty.

But, in Unity, when i desserializate the JSON i have a new instance of ErrorJSON (without info, but its created).

There is any option to avoid this?


I am using now a Json Converter that have C#.

using Newtonsoft.Json;
T objetoRetorno = JsonConvert.DeserializeObject<T>(request.downloadHandler.text);

In this case, json works like i want and dont instanciate objects if the json dont have that info.