Then, there should be a test for an empty array before actually JSON ecoding, because if ```$data[$alias]``` is not set, a JSON encoded array is what you will get.