Sorted out the JSON conversion