XML would also have a problem with this: you'd replace < with <, then with &lt;, then with &amp;lt;, … It's not exponential, but still inefficient.
There are plenty of problems to go around this approach and overall system design, but the weakest link is undoubtedly how JSON was used.