I am trying to parse a JSON which I will get from Java session variable. I am using code like this:
var foo1 = <%= session.getAttribute("json").toString() %>
var foo = JSON.parse(foo1.toString());
alert(foo.toString());
(Yes, I know scriptlets is Bad, but this is just for temporary). The value which I get with foo1 is a valid JSON (I verified with online validators). But when I try to alert the foo1 I get it as [object,Object] but if I try to parse, I get JSON.parse:Unexcpected character error.
I have uploaded JSON here, in-case if required. Since it is a bit big json string, I cannot post here.
Can someone please help me to know what wrong I am doing in this? To summary I am trying to get JSON String from Java session variable and trying to parse it in Javascript. Any tips on how to do this is appreciated.