Added JSON loading features.

There are lots of bugs though.