Closed KTW-NIRAS closed 7 years ago
Is this still required? If you enable NetJSON.IncludeTypeInformation then it should include $type for each property. And you can also use NetJSONKnownTypes to specify which class will implement the interface assuming they are user defined or you can make it automatically discover them.
Thanks,
The types are not important in this case, neither is the ability to deserialize. MVC and API controllers are outputting JSON for client side script, and for remote consumption.
It would be nice, if there was an option to treat interfaces like anonymous objects, and just serialize the contents. Type information would be unnecessary overhead in this case.
Is this possible?
Without using the type serialization option, are you getting an exception for interface properties?
Thanks,
Sorry, my bad. :-( I have just tested this on some simple data, and it works out of the box.
Maybe it has to do with serializing circular data then. This might be handled different than by Json.NET.
Thanks for helping. :+1:
I am trying to replace all references to Json.NET in a large MVC / API project, and need a serializer which can output read only properties on interfaces.
Can this be done in NetJSON?