You don't need to do the json_encode(), moodle will do it when you put the ws_format as json in the url. You only have to define the correct returning parameter function.
Web services
Remove slashes from webservice
This discussion has been locked so you can no longer reply to it.