Turning sub structures into json objects