Hi there, I've had a similar issue too. I'm consuming an API I have no control over. JSON is inconsistent when sending single or multiple. In the end, I tweaked a couple of objects.
To be honest, I only picked up the library this morning so may have chose COMPLETELY the wrong path to go down. Any feedback on my methods would be greatly appreciated. Be aware, this will only fix the problem if you have an array property but I imagine
you could extend it easily enough to take in Lists etc. The changes I made are as follows:
- Add a new member variable
- Alter the constructor to take an extra attribute
- Add a new line to the top of the constructor
_elementContract = resolver.ResolveContract(underlyingType.GetElementType())
- Add a public property to wrap the contract object
_elementContract; } }
In line 400 (on my version anyway), change the constructor of the array contract to also take "this"
JsonArrayContract contract =
Add the following block of code to CreateObject, just after an existing block of code that handles the object contract. (Line 408 in my version)
arrayContract = contract as
(arrayContract != null)
As I pointed out, this is hastily done but solves my issue.
arrayMember = CreateAndPopulateObject(reader, arrayContract.ElementContract, id);
a = Array