Fix bug in json formatting.
Revised json wrappers.