I am using the dynamic
type to read in a lot of JSON and process it. Frankly, I'd rather have intellisense. So I was wondering whether anyone has written a converter class that takes a dynamic
object and generates a static class(es) out of it.
Check out the JSON C# Class Generator:
This application generates C# classes from a sample JSON text, so you can use strongly typed programming with JSON. It currently supports typed arrays, typed objects, integers, floats, booleans, strings and nullable types.
JavaScriptSerializer.ConvertToType is ideal for this. It maps matching properties to a static type, and ignores those that don't.
You do need to give it the static type, but I think converting a dynamic to a anon static is a code smell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With