DYNDB102: Missing JSON serializer package
| Field | Value |
|---|---|
| Code | DYNDB102 |
| Severity | Error |
Message
[JsonBlob] on property '{0}' requires referencing a JSON serializer package (SystemTextJson or NewtonsoftJson)
Description
JSON blob serialization requires a JSON serializer package reference. The [JsonBlob] attribute stores complex objects as a JSON string in DynamoDB, but needs either Oproto.FluentDynamoDb.SystemTextJson or Oproto.FluentDynamoDb.NewtonsoftJson to perform the serialization.
Example
The following code triggers this diagnostic:
// Project does NOT reference SystemTextJson or NewtonsoftJson package
[DynamoDbTable("Products")]
public partial class Product
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[JsonBlob]
[DynamoDbAttribute("metadata")]
public ProductMetadata Metadata { get; set; } = new();
}
Fix
The corrected version:
<!-- Add to your .csproj file -->
<PackageReference Include="Oproto.FluentDynamoDb.SystemTextJson" />
[DynamoDbTable("Products")]
public partial class Product
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[JsonBlob]
[DynamoDbAttribute("metadata")]
public ProductMetadata Metadata { get; set; } = new();
}