json: Refactor the APIs

Refactor the `json` library taking feedback of @privat, @Morriar and @xymus into account. Also, correct some bugs related to JSON encoding/decoding and remove ad hoc escaping routines.

TODO: Support Unicode escaping.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
peut-etre rappeler quand meme la valeur de `key` pour simplifier le deboguage.

~~~~
result = new Error("Invalid key type. `Int` expected, got `{key}`.")
~~~~