schibsted / jslt

JSON query and transformation language
Apache License 2.0
638 stars 120 forks source link

generation of JSLT #336

Closed sabarinathan590 closed 8 months ago

sabarinathan590 commented 8 months ago

Hi Team,

My requirement is to create a subset of json. I'm planning to use JSLT for this transformation. Since the attributes will only be known at the run time, I need to generate JSLT on the fly (based on the attribute selection). But the problem is that the JSLT is not a valid JSON (the value is not escaped with double quotes).

Is there a recommended way to generate JSLT ? Thanks in advance.

Example:

Input Json: { "basicInfo": { "businessId": "B123" }, "managementFees": { "rate": 20 } }

User selected Attribute "$.basicInfo.businessId"

JSLT to be generated : { "basicInfo":{ "businessId":.basicInfo.businessId} }

Json subset after JSLT transformation: { "basicInfo": { "businessId": "B123" } }