Reputation: 53
Some frameworks like JSON.NET, you can serialize an object to json CamelCase naming like this:
User user1 = new User
{
UserName = "jamesn",
Enabled = true
};
DefaultContractResolver contractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy()
};
string json = JsonConvert.SerializeObject(user1, new JsonSerializerSettings
{
ContractResolver = contractResolver,
Formatting = Formatting.Indented
});
Is there any similar way how to do this using Manatee.JSON? I haven't found any documentation about this scenario.
Upvotes: 0
Views: 76
Reputation: 1
Manatee.JSON provides a delegate so that you can transform property names at serialization time.
I used the following to turn my PascalCase properties into camelCase:
var serializer = new JsonSerializer
{
Options = {SerializationNameTransform = s => s.Substring(0, 1).ToLower() + s.Substring(1)}
};
Figured out I could do this by reviewing Manatee.Json.Serialization.JsonSerializerOptions on GitHub.
Upvotes: 0