changed to use json2:encode