Sorry for not providing the complete code.
updated the code just now. problem is not with variable definition, please check the error: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)"