Replace special charachters to fix JSON

59 Views Asked by At

I'm trying to fix someone else's JSON string so that I can parse it as a real JSON object. The JSON has comma's after the last object of an array so it's not valid. I'm trying to remove it but I can't get the right formula. Any ideas?

Example string

"attributes":[]},]},

Should become

"attributes":[]}]},

I tried the following but all with no success.

string = string.replaceAll('},],', '}],');
string = string.replaceAll('\},\],', '\}\],');
string = string.replaceAll('\}\,\],', '\}\]\,');
0

There are 0 best solutions below