Working UDF with unit test for ToJson.