RM.RequestObserver
0.0.1
See the version list below for details.
dotnet add package RM.RequestObserver --version 0.0.1
NuGet\Install-Package RM.RequestObserver -Version 0.0.1
<PackageReference Include="RM.RequestObserver" Version="0.0.1" />
paket add RM.RequestObserver --version 0.0.1
#r "nuget: RM.RequestObserver, 0.0.1"
// Install RM.RequestObserver as a Cake Addin #addin nuget:?package=RM.RequestObserver&version=0.0.1 // Install RM.RequestObserver as a Cake Tool #tool nuget:?package=RM.RequestObserver&version=0.0.1
JsonMapper
Description
Map json object to another json dynamiclly using config
download source and more example : https://github.com/vahidarya14/RM.JsonMapper
sample usage source:
with this config rule
string _config = @"
f: FirstName,
l: LastName,
t:x.y.z.title,
n.m.f:FirstName,
p.q.r.f:FirstName,
p.q.r.l:LastName,
c.c:ContactDetails.Country,
a2:arr[2],
a2b:arr[2].b,
arr:arr
";
there are two ways to map jsons
using this keeps [mapping config] as rule and does all mapping using this config. no need to pass config as parameter every time
var mapper = new JsonMapper(_config);
or using static function without makeing instance of JsonMapper.it doen't keep any states and just fires and forgets
JsonMapper.Map<Source, Dest>(sourceObject, _config);
more sample
var sourceObject=new Source()
{
//...
};
var destObj = new JsonMapper(_config).Map<Source, Dest>(sourceObject);
var destObjUsingStatic = JsonMapper.Map<Source, Dest>(sourceObject, _config);
var destObjUsingWithConfig = new JsonMapper().WithConfig(_config).Map<Source, Dest>(sourceObject);
or
string _json = @"{
FirstName: ""Audrey"",
""LastName"": ""Spencer"",
""ContactDetails"": {
""Country"": ""Spain""
},
x:{
y:{
z:{
title:""t_54""
}
}
},
arr:[{a:'a1',b:'b1'},{a:'a2',b:'b2'},{a:'a3',b:'b3'}]
}";
var destObj = new JsonMapper(_config).Map< Dest>(_json);
var destinationObject = JsonMapper.Map<Dest>(_json,_config);
for inline list mapping config
ArrTarget:ArrSource{
AgeOfVehicle:Age,
FullName:Name
}
here is the complete sample
string _config = @"
Year: Year,
ArrTarget:ArrSource{
AgeOfVehicle:Age,
FullName:Name
}
";
_source =new Source3{
Year=1986,
ArrSource=new List<Arr3>
{
new Arr3(){Age=20,Name="ford"},
new Arr3(){Age=30,Name="benz"}
}
};
var destObj = new JsonMapper(_config).Map<Source3, Dest3>(_source);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net7.0
- Microsoft.Extensions.Primitives (>= 7.0.0)
- UAParser (>= 3.1.47)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.