如何在JSON文件中定义变量并在JSON文件中使用它 [英] How to define a variable within a JSON file and use it within JSON file
本文介绍了如何在JSON文件中定义变量并在JSON文件中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要查找JSON文件是否支持定义变量并在该JSON文件中使用它们?
I'm trying to find if JSON file supports defining variables and using them within that JSON file?
{
"artifactory_repo": "toplevel_virtual_NonSnapshot",
"definedVariable1": "INSTANCE1",
"passedVariable2": "${passedFromOutside}",
"products": [
{ "name": "product_${definedVariable1}_common",
"version": "1.1.0"
},
{ "name": "product_{{passedVariable2}}_common",
"version": 1.5.1
}
]
}
我知道YAML文件允许这样做,但是现在确定JSON文件是否允许这种行为.我的计划是,用户将通过Jenkins传递"definedVariable"值,然后我将创建一个目标JSON文件(在substi之后
I know YAML files allow this but now sure if JSON file allows this behavior or not. My plan is that a user will pass "definedVariable" value from Jenkins and I'll create a target JSON file (after substi
推荐答案
这可能会帮助您:
{
"artifactory_repo": "toplevel_virtual_NonSnapshot",
"definedVariable1": "INSTANCE1",
"passedVariable2": `${passedFromOutside}`,
"products": [
{ "name": `product_${definedVariable1}_common`,
"version": "1.1.0"
},
{ "name": `product_${passedVariable2}_common`,
"version": 1.5.1
}
]
}
*请注意使用``而不是''
*Note the use of `` instead of ''
这篇关于如何在JSON文件中定义变量并在JSON文件中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文