Open kripajoym opened 5 years ago
Hi @kripajoym,
sorry for the late reply, hopefully later is better than never.
I made this script locally to see what gets rendered by mustache with the template you provided above and one of the DisplayValue
s that contains double quotes:
const mustache = require('mustache')
const template = '{ \"Value\" : \"{{{Id}}}\", \"DisplayValue\" : \"{{{Name}}}\" }'
console.log(mustache.render(template, {
Id: 'some-unique-ID', Name: 'AppWith"Quotes'
}))
// outputs:
// { "Value" : "some-unique-ID", "DisplayValue" : "AppWith"Quotes" }
As I'm not familiar with Azure VSTS, I'm not entirely sure how much you've got control of (like the template?) and what should be returned from the template. Nevertheless the DisplayValue
above surely doesn't look like valid JSON if that's what it's supposed to be, as the double quite inside "AppWith"Quotes"
isn't a valid JSON string since it's terminated in the middle.
Ensuring valid JSON is rendered, is sadly not a responsibility mustache is willing to take.
Do you have control of the template? The first thought that comes to mind escaping the DisplayValue
somehow. I.e. by using two mustaches instead of three ({{Name}}
) or JSON.stringify()
the DisplayValue
before it's provided to mustache? ..again this depends on how much you control in Azure-land.
"resultselector":"jsonpath:$.[*]"
"resultTemplate":"{ \"Value\" : \"{{{Id}}}\", \"DisplayValue\" : \"{{{Name}}}\" }"
Am calling an API and it is returning a set of data.
While fetching the key value pairs, If DisplayValue-Name contains double quotes (eg. "AppWithQuotes" or AppWith"Quotes), the dropdown is displaying the entire key value pair as it is (Refer the Link ) For other cases (when double quotes are not present), the drop down displays the DisplayValue name alone as expected (eg. Demo/123).