I am communicating with a third party API that returns JSON responses as follows:
\"{\\\"SomeResponse\\\":{\\\"FIrstAttribute\\\":8,\\\"SecondAttribute\\\":\
Ugh... that's not JSON at all. It's a weird JSON-like imitation, but a pretty nasty one. I think you're doing the right thing.
The only thing that I might do is do the replace operation on pairs of characters rather than just the single escape char:
myString.Replace(@"\""", @"""); // replace \" with "
This will allow you to safely preserve the nested "\" chararcters, so that the filtered JSON looks like:
field_blah: "root\branch\sub-branch"
I strongly advise undertaking a detailed review of the "JSON" text and ensuring that this is the only paired sequence you need to worry about. If you have other pairings, handle them in the same manner as outlined above.