I don’t know I understand exactly what you want to do but from your example you mast want to remove last come. If there is always closing bracket ‘]’ at the end you can use;
str = [str stringByReplacingOccurrencesOfString:@" ,]" withString:@"]"];
Hope this is what you are after.
solved Remove a character once