use json_encode on variables nested in JS
Merge pull request #1 from cythrawll/patch-1

use json_encode on variables nested in JS