Json serializing

In the works pull request for merging with master