本文整理匯總了TypeScript中webdeployment-common/jsonvariablesubstitutionutility.js.default.stripJsonComments方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.default.stripJsonComments方法的具體用法?TypeScript js.default.stripJsonComments怎麽用?TypeScript js.default.stripJsonComments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類webdeployment-common/jsonvariablesubstitutionutility.js.default
的用法示例。
在下文中一共展示了js.default.stripJsonComments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: validateInvalidJSONWithComments
function validateInvalidJSONWithComments() {
var fileContent: string = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'InvalidJSONWithComments.json'), 'utf-8');
var jsonContent: string = jsonSubUtil.stripJsonComments(fileContent);
try {
var jsonObject = JSON.parse(jsonContent);
throw new Error('JSON VAR SUB FAIL #6');
}
catch(error) {
console.log("INVALID JSON COMMENTS TESTS PASSED");
}
}
示例2: validateJSONWithComments
function validateJSONWithComments() {
var fileContent: string = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'JSONWithComments.json'), 'utf-8');
var jsonContent: string = jsonSubUtil.stripJsonComments(fileContent);
var jsonObject = JSON.parse(jsonContent);
jsonSubUtil.substituteJsonVariable(jsonObject, envVarObject);
if(jsonObject['dataSourceBindings']['0']['target'] != 'AppServiceName') {
throw new Error('JSON VAR SUB FAIL #1');
}
if(jsonObject['name'] != 'App Service Deploy') {
throw new Error('JSON VAR SUB FAIL #2');
}
if(jsonObject['Hello']['World'] != 'Hello World') {
throw new Error('JSON VAR SUB FAIL #3');
}
if(jsonObject['dataSourceBindings']['1']['parameters']['WebAppName'] != 'App Service Name params') {
throw new Error('JSON VAR SUB FAIL #4');
}
if(jsonObject['messages']['Invalidwebapppackageorfolderpathprovided'] != 'Invalidwebapppackageorfolderpathprovided') {
throw new Error('JSON VAR SUB FAIL #5');
}
console.log("VALID JSON COMMENTS TESTS PASSED");
}