Be a bit smarter with json conversion