Closed alesrazym closed 5 years ago
And how will making JSONParameters.MakeCopy()
public help?
I don't want to change global JSON.Parameters
itself, used widely in JSON.ToJSON(object)
, but make a copy to change just a subset of parameters and use it in JSON.ToJSON(object, JSON.Parameters)
.
For example I do not want to serialize type in global settings, but do want for some special case.
If I can make copy, then I can safely change one parameter withou knowing the others settings.
You can easily do that right now :
var jp1 = new JSONParameters { UseExtensions = false }; // everything else as default
var jp2 = new JSONParameters { UseFastGuid = false };
There is one global JSON.Parameters
setup like that, changing few parameters.
I want to prevent any future change to global parameters to make a bug somewhere else by not inserting the change to other place in code where parameters are created. So whatever the JSON.Parameters
are, I want to be sure to have a copy and change just one (or few) parameters.
Instead of:
JSON.Parameters = new JSONParameters
{
something = true,
...,
somethingElse = false
}
...
JSONParameters other = new JSONParameters
{
something = true,
...,
somethingElse = false,
UseExtensions = true
}
I want to have:
JSON.Parameters = new JSONParameters
{
something = true,
...,
somethingElse = false
}
...
JSONParameters other = JSON.Parameters.MakeCopy();
other.UseExtensions = true;
Made it public in v2.2.3.1
thank you sir
I'd like to have option to (de)serialize some data with different
JSONParameters
, based on globalJSON.Parameters
.JSON.DeepCopy<JSONParameters>()
fails andJSONParameters.MakeCopy()
is not public. Is there any other solution? Is it possible to makeJSONParameters.MakeCopy()
public?