Changed API to work with JSON.