The VarRef identifies a variable name in a specific context.  The JSON returned does not identify that variable or relate to that context.  You look up the value of the variable (or of the variables, IIUC, when it's an array's name) and represent that **value** (or those values) in JSON - or have I hugely misunderstood what this function does ? - if so, it needs some documentation !  Well, some documentation would be good anyway.