SIPS.Adapter
1.0.2
dotnet add package SIPS.Adapter --version 1.0.2
NuGet\Install-Package SIPS.Adapter -Version 1.0.2
<PackageReference Include="SIPS.Adapter" Version="1.0.2" />
<PackageVersion Include="SIPS.Adapter" Version="1.0.2" />
<PackageReference Include="SIPS.Adapter" />
paket add SIPS.Adapter --version 1.0.2
#r "nuget: SIPS.Adapter, 1.0.2"
#:package SIPS.Adapter@1.0.2
#addin nuget:?package=SIPS.Adapter&version=1.0.2
#tool nuget:?package=SIPS.Adapter&version=1.0.2
SIPS Adapter
This package provides a JSON adapter for SIPS.
Overview
- Implements essential JSON conversion for SIPS integration.
- Follows NuGet best practices for package documentation.
JSON Mapping Details
The adapter translates JSON from the request body to the internal system JSON format using the following mappings:
- "InternalField": Maps to the internal system field.
- "UserField": Maps to the value provided by the user.
- "Type": Specifies the type of the JSON payload.
Usage
To use the adapter, follow these steps:
- Install the package.
- Add the package to your IServiceCollection.
- Use the IJsonAdapter interface to convert the JSON.
services.AddJsonAdapter();
var jsonAdapter = serviceProvider.GetRequiredService<IJsonAdapter>();
// Provide the endpoint name that corresponds to your configured mapping
var internalJson = jsonAdapter.Transform(userJson, endpointName);
Configuring Endpoint Mappings
The adapter requires an endpointName to determine how to map incoming JSON. Provide a configured JsonAdapterOptions instance via DI (the library registers an empty default you can replace):
using SIPS.Adapter.Models;
services.AddSingleton(new JsonAdapterOptions
{
Endpoints = new Dictionary<string, EndpointMapping>
{
["createPayment"] = new EndpointMapping
{
FieldMappings = new List<FieldMapping>
{
new FieldMapping { InternalField = "amount", UserField = "data.amount", Type = MappingType.Int },
new FieldMapping { InternalField = "reference", UserField = "data.ref", Type = MappingType.String },
new FieldMapping { InternalField = "timestamp", UserField = "meta.createdAt", Type = MappingType.DateTime }
}
}
}
});
// Later
var mapped = jsonAdapter.Transform(userJson, "createPayment");
Reverse Mapping From Object to External JSON
To map from a local object into an external (user) JSON shape, use the generic overload:
var userJsonOut = jsonAdapter.Transform(localObject, endpointName);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Logging (>= 9.0.1)
- Microsoft.Extensions.Options (>= 9.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SIPS.Adapter:
| Package | Downloads |
|---|---|
|
SIPS.Core
SIPS CORE |
GitHub repositories
This package is not used by any popular GitHub repositories.