Loading ...
Sorry, an error occurred while loading the content.

664Re: [json] json object from cookie

Expand Messages
  • mark
    Jan 15, 2007
      i did :
      alert(typeof(json_text_string))


      i got string as the type.
      and after i did an eval again i did this again for which i got the type as
      "object".
      mark
      On 1/15/07, Mark Ireland <markincuba@...> wrote:
      >
      >
      > What test do you do to show that your string is not a JSON object?
      >
      > >From: mark <rkmr.em@... <rkmr.em%40gmail.com>>
      > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
      > >To: json@yahoogroups.com <json%40yahoogroups.com>
      > >Subject: [json] json object from cookie
      > >Date: Mon, 15 Jan 2007 17:00:31 -0800
      > >
      > >I am trying to get JSON object from a JSON string in a cookie. When I
      > >convert the string read from cookie, i still get a string and not a JSON
      > >object. So i did an eval on the string again and I get the JSON object
      > >fine.
      > >is this the right way to do this?
      > >what am i doing wrong?
      > >
      > >thanks
      > >mark
      > >
      > >
      > >here is what i do:
      > >var json_text=getcookie('sub_options');
      > >var json_text_string = eval('(' + json_text + ')');
      > >var options_list= eval('(' + json_text_string + ')');
      > >
      > >//to get cookie
      > >function getcookie(cookiename) {
      > >var cookiestring=""+document.cookie;
      > >var index1=cookiestring.indexOf(cookiename);
      > >if (index1==-1 || cookiename=="") return "";
      > >var index2=cookiestring.indexOf(';',index1);
      > >if (index2==-1) index2=cookiestring.length;
      > >return unescape(cookiestring.substring
      > (index1+cookiename.length+1,index2));
      > >}
      > >
      > >
      > >[Non-text portions of this message have been removed]
      > >
      >
      > __________________________________________________________
      > Advertisement: Meet Sexy Singles Today @ Lavalife - Click here
      >
      > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D23769&_t=754951090&_r=endtext_lavalife_dec_meet&_m=EXT
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 13 messages in this topic