Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore a field on serialization not working as intended #329

Open
kvpt opened this issue Oct 24, 2024 · 1 comment
Open

Ignore a field on serialization not working as intended #329

kvpt opened this issue Oct 24, 2024 · 1 comment

Comments

@kvpt
Copy link

kvpt commented Oct 24, 2024

Hi,

I encounter a serialization issue in a test that use Verify which use this library to serialize data.

I have a field that I want to ignore and it doesn't seem to work.

From the documentation, there is two ways to ignore a field, by using JsonIgnore or NonSerialized attribute.

I have tested the two options and reproduced it in this simple snippet :

void Main()
{
	var product = new Data
	{
	    Name = "Test",
	    Private = "Private"
	};
	
	var json = Argon.JsonConvert.SerializeObject(product);
	
	json.Dump();
}

[Serializable]
public class Data
{
        public string Name { get; set; }
	
	[NonSerialized]
	[JsonIgnore]
	public string Private;
}

By searching in the code I have found that IgnoreDataMember attribute is also checked and this seems to work, but it's not documented so I don't known if it's intended to work that way or not.

@SimonCropp
Copy link
Owner

happy to consider a pull request that fixes this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants