Yes but please don't call it VarRefToJson. These XToY functions are conventially convert function names, they follow a standard signature. Just name it something else, and please use const if possible.