Powershell“ ConvertTo-Json”将json格式的输出弄乱了

时间:2018-11-13 18:26:06

标签: json powershell arm-template

1)$ Getjsonfilecontent =获取内容“ C:\ Scripts \ CreateADF-Datasets \ BUSI_RULE_BUILD_LOCATION_CODES_Source_Def.json”-原始| ConvertFrom-Json

2)将一些密钥对值附加到json文件

3)$ Getjsonfilecontent | ConvertTo-Json-深度100 | %{[System.Text.RegularExpressions.Regex] :: Unescape($ _)} | set-content $ Updatedleafjsonpath(Updatedleafjsonpath是基础文件“ Getjsonfilecontent”的副本)

当我这样做时,看到“ $ Updatedleafjsonpath”中的某些格式混乱,如下所示。所有的“ \”都丢失了,“ \ n”在我的输出中也被弄乱了。 注意:同一json文件中还有另一个部分是步骤2的一部分,该部分使用密钥对值进行了udp替换,但是该部分没有udp替换,应该在转换前后保持不变。 我们对此表示任何帮助。

Input: same output is expected.
 "typeProperties": {
                "format": {
                    "type": "TextFormat",
                    "columnDelimiter": "|",
                    "rowDelimiter": "\n",
                    "quoteChar": "\"",
                    "nullValue": "\"\"",
                    "encodingName": null,
                    "treatEmptyAsNull": true,
                    "skipLineCount": 0,
                    "firstRowAsHeader": false
                },
                "fileName": "[parameters('Veh_Obj_properties_typeProperties_fileName')]",
                "folderPath": "[parameters('Veh_Obj_properties_typeProperties_folderPath')]"
            }
                                             }

转换后我得到了什么:

"typeProperties":  {
                                                                "format":  {
                                                                               "type":  "TextFormat",
                                                                               "columnDelimiter":  "|",
                                                                               "rowDelimiter":  "
",
                                                                               "quoteChar":  """,
                                                                               "nullValue":  """",
                                                                               "encodingName":  null,
                                                                               "treatEmptyAsNull":  true,
                                                                               "skipLineCount":  0,
                                                                               "firstRowAsHeader":  false
                                                                           },
                                                                "fileName":  "[parameters('Veh_Obj_properties_typeProperties_fileName')]",
                                                                "folderPath":  "[parameters('Veh_Obj_properties_typeProperties_folderPath')]"
                                                            }

1 个答案:

答案 0 :(得分:0)

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    var cell = collectionView.dequeueReusableCell(withReuseIdentifier: "LetterCell", for: indexPath) as! LetterCell
    cell.singleLetterTextField.text = data[row][column]

    increaseRowColumn()

    return cell
}