小编Ram*_*Ram的帖子

使用 powershell 为 json 添加新的键值对

我正在创建一个 arm 模板来在 ADF 中部署数据集,为此我需要根据我的输入文件使用新的键值对更新现有的 json 文件。如何使用 powershell 向 json 文件添加新的键值对。对此的任何帮助都非常感谢..

如果正在使用“添加成员”,它将使用新的“键”和“值”更新结构中的所有属性,如下所示。但我希望在另一个值对之后添加新的键和值,就像我在远处显示的那样下面用“需要添加这个”突出显示的代码

                {
                    "name": "VIN",
                    "type": "String"
                    "newkey1" : "newvalue1"
                    "newkey2" : "newvalue2"
                },
                {
                    "name": "MAKE",
                    "type": "String"
                     "newkey1" : "newvalue1"
                    "newkey2" : "newvalue2"

                },
Run Code Online (Sandbox Code Playgroud)

我的代码应该看起来像这样..“需要添加这个”是我打算在每个循环中添加的键值对,只要我有来自另一个文本文件的输入。

    {
        "name": "[concat(parameters('factoryName'), '/Veh_Obj')]",
        "type": "Microsoft.DataFactory/factories/datasets",
        "apiVersion": "2018-06-01",
        "properties": {
            "linkedServiceName": {
                "referenceName": "AzureDataLakeStore1",
                "type": "LinkedServiceReference"
            },
            "annotations": [],
            "type": "AzureDataLakeStoreFile",
            "structure": [
                {
                    "name": "VIN",
                    "type": "String"
                },
                {
                    "name": "MAKE",
                    "type": "String"
                },
                {
                    "Need to add this": "Need to add …
Run Code Online (Sandbox Code Playgroud)

powershell json azure-rm-template

2
推荐指数
1
解决办法
2199
查看次数

标签 统计

azure-rm-template ×1

json ×1

powershell ×1