I was playing around with impromptu interface over a jobject and ran into the following issue
https://code.google.com/p/impromptu-interface/issues/detail?id=17
The issue is marked as 'Won't fix' and in the comments the author says that it could be fixed by implementing a custom impromptuobject.
Anyone have a sample of such an implementation? Or know another solution to this problem?
So the problem is that
JArray
has GetEnumerator() defined as interface-only, which makes the method no longer duck callable by the DLR. So below I've overriden thetrygetmember
to check if the result is aJArray
's and convert it to aJEnumerable
that implements GetEnumerator() in a dlr invokable way.However, this will only work for json structures that don't have arrays more then one property deep. You'll either have modify the above to recursively check anytime anything is returned maybe with a proxy, or modify the dictionary indexer's
set
to check and convert when deserialized instead.Update: Json.net verion >= 5.0.4.16101 and ImpromptuInterface >= 6.1.4 will work out of the box.