Initial revision of ToJSON() UDF, with accompanying test case.