Revert "Combine JavaScript and JSON encoding logic" and follow-ups

I found out that the PHP JSON extension has non-free components
from JSON.org, licensed under the notorious "Good, not Evil"
license. So I'm reverting this on REL1_21 while I figure out a
solution to be merged into master.

It should be easy to run MediaWiki using only free/open source
software.

This reverts commits:
* 443fac7ca747f2ed2ce145acd7f76ff5bed51315
* 75e5b7ea7c46d70924ed8a6c764f3454f7570540
* d828e87176d2f7311ed5d98a61ad2237c769c175

Bug: 47431
Change-Id: Id3b88102e768318e3605a19e9952121091a40915