I have text per below (from an api response).
$a = '[
{
"Id": "65486432",
"RecordType": 20
},
{
"Id": "d1b2abe9",
"RecordType": 20,
"ModelsSnapshots": []
}
]
[
{
"Id": "65486432",
"RecordType": 20
},
{
"Id": "d1b2abe9",
"RecordType": 20,
"ModelsSnapshots": []
}
]'
I need to replace the square brackets in the middle with ","
]
[
So the final output should be like. Note there are also "[]" in the text that I don't want to change.
'[
{
"Id": "65486432",
"RecordType": 20
},
{
"Id": "d1b2abe9",
"RecordType": 20,
"ModelsSnapshots": []
}
,
{
"Id": "65486432",
"RecordType": 20
},
{
"Id": "d1b2abe9",
"RecordType": 20,
"ModelsSnapshots": []
}
]'
I've tried the following with no luck:
$a -replace "\]`n\[", ","
This works in this example, but not in the actual file, so other alternative solutions would be appreciated.