Skip to content

camous/acmemapper

Repository files navigation

Nuget

ACMEMAPPER

ACMEMAPPER has been developed focusing on mapping definition maintainability & lisibility over flexibility & performance: mapping definitions are declared in JSON and reloaded on each new ACMEMAPPER object. Many source or destination objects type are supported such JObject or any POCO ones. ACMEMAPPER has been initiality developed in context of an Enterprise Service Bus which has to support & manage many mapping activities and update mapping definitions without re-build & deploy.

Simple mapping example

Mapping definition

{
    "myobjecttype" : [
        {
            "systemA" : "systemAfield1",
            "systemB" : "systemBfield1"
        },
        {
            "systemA" : "systemAfield2",
            "systemB" : "systemBfield2"
        }
    ]
}

C# source code with

    using acmemapper;
    ...
    var mapper = new Mapper("systemA", "systemB");
    var output = mapper.Map<JObject,JObject>("myobjecttype",new JObject { { "systemAfield1" , "mystringvalue" } });

JObject/JSON output

{
    "systemBfield1" : "mystringvalue"
}

Another example

A sligthly more complex mapping definition including modifiers

{
  "myobjecttype": [
    {
      "systemA": "systemAfield2",
      "systemB": {
        "property": "systemBfield2",
        "fromsubproperty": "nestedsourceproperty",
        "tosubproperty": "nesteddestinationproperty",
        "ignoreIfNull": true,
        "invoke": "ToUpperInvariant",
        "map": {
          "MYSTRINGVALUE": "mappedvalueinupperletter",
          "mystringvalue": "mappedvalueinsmallletter",
          "myintegervalue": 1,
          "$default": false
        }
      }
    }
  ]
}

JSON input

{
	"systemAfield2": {
		"nestedsourceproperty": "mystringvalue"
	}
}

JSON output

{
    "systemBfield2": {
        "nesteddestinationproperty": "mappedvalueinupperletter"
    }
}

HOW TO

Features

  • Double direction mapping
  • Nested JSON content mapping
  • 1...N mapping definition
  • N...1 overwrite support
  • N...array support
  • POCO basic object composition
  • Control flags : Ignore / IgnoreIfNull
  • Basic casting
  • Basic transformation : switch (map)
  • Parameterless method invokation (eg. ToLowerInvariant)
  • Basic regex support (regex)

modifiers orders

Limitations

ACMEMAPPER supports by design several entity definitions and no limitation of source & destination systems (including both way mapping). By design, ACMEMAPPER supports only as input 2 levels of data (either JSON or POCO object)

{
    "level1field" : "value1",
    "nestedobject" : {
        "level2field" : "subvalue2"
    }
}

About

JSON declarative mapping engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages