This would be the right way to do this, but the problem is that in php, an empty map is indistinguishable from an empty list. So how do we tell the json encoder when to use what?