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

Fails to deserialize List<T> when T[] succeeds #332

Open
kstreichergb opened this issue Sep 23, 2019 · 0 comments
Open

Fails to deserialize List<T> when T[] succeeds #332

kstreichergb opened this issue Sep 23, 2019 · 0 comments

Comments

@kstreichergb
Copy link

[
	{
		"id": "5d88c128ca43bc00084b60b2",
		"entityId": "68581f16-18c7-4dbf-93dd-237c291a085c"
	}
]

Cannot be deserialized into

	public class MatchingResultDto
	{
		[DataMember(Name = "id")] public string Id { get; set; }
		[DataMember(Name = "entityId")] public Guid EntityId { get; set; }
	}

Deserialization throws Unexpected ]

using (var input = new StringReader(result))
				{
					var deserializedArray = JSON.Deserialize<MatchingResultDto[]>(input, jilOptions);
					var deserializedList = JSON.Deserialize<List<MatchingResultDto>>(input, jilOptions); // This fails
					var results = deserializedArray?.ToList() ?? new List<MatchingResultDto>();
				}

But Array serialization works.

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

1 participant