Only json encode when its an array.