Skip to main content

NewtonsoftJson

NuGet Version NuGet Downloads

Newtonsoft.Json (Json.NET) serialization support for FluentDynamoDB. Use this package for compatibility with existing Newtonsoft.Json-based projects or when you need advanced features like polymorphic serialization.

Installation​

dotnet add package Oproto.FluentDynamoDb.NewtonsoftJson

Key Features​

  • Compatibility - Works with existing Newtonsoft.Json configurations
  • Rich Feature Set - Access to all Newtonsoft.Json features including polymorphic serialization
  • Custom Converters - Built-in converters for DynamoDB-specific types
  • Flexible Configuration - Full control over serialization settings via FluentDynamoDbOptions

Quick Start​

Configure Newtonsoft.Json at runtime using FluentDynamoDbOptions:

using Oproto.FluentDynamoDb;
using Oproto.FluentDynamoDb.NewtonsoftJson;

// Default settings
var options = new FluentDynamoDbOptions()
.WithNewtonsoftJson();

var table = new DocumentTable(dynamoDbClient, "documents", options);

Custom JsonSerializerSettings​

Pass custom JsonSerializerSettings to control serialization behavior:

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

var jsonSettings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = NullValueHandling.Ignore,
DateFormatHandling = DateFormatHandling.IsoDateFormat,
Formatting = Formatting.None
};

var options = new FluentDynamoDbOptions()
.WithNewtonsoftJson(jsonSettings);

var table = new DocumentTable(dynamoDbClient, "documents", options);

When to Use Newtonsoft.Json​

Consider Newtonsoft.Json when you need:

  • Polymorphic serialization with TypeNameHandling
  • Custom contract resolvers for complex mapping scenarios
  • Reference handling for circular references
  • Compatibility with existing Newtonsoft.Json infrastructure

For new projects without these requirements, consider using System.Text.Json for better performance and AOT support.

Documentation​

For complete documentation including entity definitions, usage examples, and polymorphic serialization, see the Newtonsoft.Json Serialization Guide.

NuGet​

View on NuGet.org