-
Notifications
You must be signed in to change notification settings - Fork 143
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
Support serialization of Newtonsoft JSON.NET JObject #40
Comments
can u post a sample code of class and json you are trying to serialize/deserialize. |
I just pushed 2 failing unit tests to my fork |
Why would you want to use both at the same time in the same code? The only place where you would want to use both at the same place would be server side using webapi and in client use simplejson. |
In this case I'm building a logging library which serializes objects using SimpleJson. A consumer of this library is using WebApi with the default Json.Net serializer and sending the objects to log to my library. For now I provided him a SimpleJsonFormatter for WebApi and it solved the particular issue. But I would not like to force the library consumers to make this kind of changes. Maybe the solution is to have a hook where I can define a TypeConverter like Json.Net to force a type to use a specific converter before evaluating the default ones, as JObject is not able to reach the TrySerializeNonPrimitiveObject method. |
You might be interested in this discussion. https://twitter.com/PrabirShrestha/status/271392381226590209 Since |
Right, that could help, I will give that a try, thanks |
Ok, I'm back on this after a while, casting as
It will check if the type to be serialized is an What do you think? |
As the Newtonsoft JSON.NET JObject implements IEnumerable it is treated as an array for serialization instead of being serialized directly.
My issue came up in the following case: ASP.NET WebApi used JSON.NET to deserialize a complex JSON object during an API request. The deserialized type contains an
IDictionary<string, object>
property to allow custom info to be sent to the API. As part of the WebApi deserialization all the entries in the dictionary had JObject instance values. Trying to serialize the type instance again using SimpleJson the dictionary is not correctly serialized.Thanks,
Eduardo
The text was updated successfully, but these errors were encountered: