Skip to main content

JSLT Client Integration

Here we are some steps to be followed for implementing JSLT Client to your service.

JSLT Client is the *nuget package belongs to *cm.comwhich implements both JSLT Service and Client Service. Which can be use to transform JSON data from one form to another with the help of templates.

**Let' s Start: **​

Step 1:​

Download Latest Version ** CM.Connect.Common.JSLTClient**nuget package.

or

Run following command

nuget install CM.Connect.Common.JSLTClient -Version 2.0.0 -Source https://proget2.sharedservices.cmgroep.local/nuget/CMFeed/

or

Install from the Package Manager Console within Visual Studio, run the following command:

Install-Package CM.Connect.Common.JSLTClient -Version 2.0.0 -Source https://proget2.sharedservices.cmgroep.local/nuget/CMFeed/

**Note: **Make sure to download latest Release Version

Step 2:​

In your appsettings.json add following lines in parent level:

"JSLTClientSettings": {
"JsltServiceBaseUrl": "https://jsltservice-3tmvxtxoxq-ez.a.run.app",
"ConfigurationServiceBaseUrl": "https://configuration-3tmvxtxoxq-ez.a.run.app",
"ConfigurationServiceAuthToken": "AUTH_TOKEN"
},

**Warning: **Don’t Change the value of JSLTServiceBaseURLand TemplateServiceBaseURL

Step 3:​

In your Program.cs file insert following line.

builder.Services.Configure<JsltClientOptions>(builder.Configuration.GetSection("JSLTClientSettings"));
builder.Services.AddJsltClient();

All setup done ! Now it is time to implement !

Step 4:​

Now in your controller

  • Select the function where you want to implement transformation.
  • make it async.
  • Add the following code before returning the original response.
var result = FUNCTION_TO_GET_ORIGNAL_RESPONSE() //it is not part of JSLT Client.

/*Here is code to implement transformation*/
var response = await _jsltClient.TransformAsync(CONFIG_ID, SERVICE_ID, YOUR_JSON_ELEMENT);
return Ok(response);