libpromises/evalfunction.c: let mergedata() use VarRefValueToJson

Trivial PR, doesn't change the operation of `mergedata()` but cuts 90 lines of code and simplifies it nicely.