Open subodhrathi opened 3 years ago
This is my first time using Jolt and I am amazed at transformations it can perform. I followed the documentation and few posts online.
However, I am still have challenges with:
I have the following input: { "Body": [ { "username": "some-user" }, { "password": "*******" } ], "hostSource": "infos", "Host": [ { "HOST_NAME": "xyz.com" }, { "PORT": "9085" } ], "Headers": [ { "Content-Type": "application/json" } ]
{ "Body": [ { "username": "some-user" }, { "password": "*******" } ], "hostSource": "infos", "Host": [ { "HOST_NAME": "xyz.com" }, { "PORT": "9085" } ], "Headers": [ { "Content-Type": "application/json" } ]
Expected Output is: { "templateConfig": { "commonClientConfig ": { "item": [ { "name": "Main API - BASICAUTH", "request": { "auth": { "type": "basic", "basic": [ { "key": "password", "value": "*******", "type": "string" }, { "key": "username", "value": "some-user", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text" } ], "url": { "raw": "xyz.com/v9085/some-default-value" } } } ] } }
{ "templateConfig": { "commonClientConfig ": { "item": [ { "name": "Main API - BASICAUTH", "request": { "auth": { "type": "basic", "basic": [ { "key": "password", "value": "*******", "type": "string" }, { "key": "username", "value": "some-user", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text" } ], "url": { "raw": "xyz.com/v9085/some-default-value" } } } ] } }
I was able to get this far with the spec based on online posts/documentation. [ { "operation": "shift", "spec": { "Body": { "*": { "*": { "$": "commonClientConfig.item.request.auth.basic[&2].key", "@(1,&)": "commonClientConfig.item.request.auth.basic[&2].value" } } }, "Headers": { "*": { "*": { "$": "commonClientConfig.item.request.header[&2].key", "@(1,&)": "commonClientConfig.item.request.header[&2].value" } } }, "Host": { "*": { "*": { "@(1,&)": "commonClientConfig.item.request.url.raw" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "content": "=join('/', @(2,commonClientConfig.item.request.url.raw))" } } ]
[ { "operation": "shift", "spec": { "Body": { "*": { "*": { "$": "commonClientConfig.item.request.auth.basic[&2].key", "@(1,&)": "commonClientConfig.item.request.auth.basic[&2].value" } } }, "Headers": { "*": { "*": { "$": "commonClientConfig.item.request.header[&2].key", "@(1,&)": "commonClientConfig.item.request.header[&2].value" } } }, "Host": { "*": { "*": { "@(1,&)": "commonClientConfig.item.request.url.raw" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "content": "=join('/', @(2,commonClientConfig.item.request.url.raw))" } } ]
Would need some guidance on spec along with explanation to achieve desired output.
This is my first time using Jolt and I am amazed at transformations it can perform. I followed the documentation and few posts online.
However, I am still have challenges with:
I have the following input:
{ "Body": [ { "username": "some-user" }, { "password": "*******" } ], "hostSource": "infos", "Host": [ { "HOST_NAME": "xyz.com" }, { "PORT": "9085" } ], "Headers": [ { "Content-Type": "application/json" } ]
Expected Output is:
{ "templateConfig": { "commonClientConfig ": { "item": [ { "name": "Main API - BASICAUTH", "request": { "auth": { "type": "basic", "basic": [ { "key": "password", "value": "*******", "type": "string" }, { "key": "username", "value": "some-user", "type": "string" } ] }, "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json", "type": "text" } ], "url": { "raw": "xyz.com/v9085/some-default-value" } } } ] } }
I was able to get this far with the spec based on online posts/documentation.
[ { "operation": "shift", "spec": { "Body": { "*": { "*": { "$": "commonClientConfig.item.request.auth.basic[&2].key", "@(1,&)": "commonClientConfig.item.request.auth.basic[&2].value" } } }, "Headers": { "*": { "*": { "$": "commonClientConfig.item.request.header[&2].key", "@(1,&)": "commonClientConfig.item.request.header[&2].value" } } }, "Host": { "*": { "*": { "@(1,&)": "commonClientConfig.item.request.url.raw" } } } } }, { "operation": "modify-overwrite-beta", "spec": { "content": "=join('/', @(2,commonClientConfig.item.request.url.raw))" } } ]
Would need some guidance on spec along with explanation to achieve desired output.