Trying to read a specific Json file from disc but the ConvertFrom-Json is not converting properly. Using old school powershell but same issue with pwsh (Core)
The json file on disc is the following :
[{
"pipeline_type": "WORKSPACE",
"name": "Data Foundation Process",
"clusters": [
{
"label": "default",
"num_workers": 5
}
],
"libraries": [
{
"notebook": {
"path": "//Shared//DataFoundation//Ingestion"
}
},
{
"notebook": {
"path": "/Shared/DataFoundation/Transformation"
}
}
],
"target": "DataFoundation",
"continuous": false,
"development": true,
"photon": false,
"edition": "ADVANCED",
"channel": "CURRENT",
"data_sampling": false
},
{
"pipeline_type": "WORKSPACE",
"name": "Data Foundation Process 2",
"clusters": [
{
"label": "default",
"num_workers": 5
}
],
"libraries": [
{
"notebook": {
"path": "/Shared/DataFoundation/Ingestion"
}
},
{
"notebook": {
"path": "/Shared/DataFoundation/Transformation"
}
}
],
"target": "DataFoundation",
"continuous": false,
"development": true,
"photon": false,
"edition": "ADVANCED",
"channel": "CURRENT",
"data_sampling": false
}
]
If you apply ConvertFrom-Json to it, it will screw up the path property of the notebooks in the libraries section. When you convert it back to json with ConvertTo-Json, it results in this
{
"notebook": "@{path=/Shared/DataFoundation/Ingestion}"
}
instead of this
{
"notebook": {
"path": "/Shared/DataFoundation/Ingestion"
}
}
Any suggestions on how to avoid this? Tried the -AsHashtable approach but since we can have multiple objects in the array, this won’t work because I’m using a ForEach-Object to process each object as a whole.