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

Re: [json] Re: json object from cookie

Expand Messages
  • mark
    ... I can not see an example. There is just a javascript validator? mark [Non-text portions of this message have been removed]
    Message 1 of 13 , Jan 16, 2007
      On 1/16/07, Douglas Crockford <douglas@...> wrote:
      >
      > > 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?
      >
      > An example of the use of JSON cookies can be found at
      > http://www.JSLint.com/index.html
      >











      I can not see an example. There is just a javascript validator?
      mark


      [Non-text portions of this message have been removed]
    • Mark Ireland
      Could it be that the typeof() function just isnt that clever? { means - could be an object? anything else ie [ that is definitely not an array - could be a
      Message 2 of 13 , Jan 16, 2007
        Could it be that the typeof() function just isnt that clever?

        '{' means - could be an object?

        anything else ie '[' that is definitely not an array - could be a string?


        >From: mark <rkmr.em@...>
        >Reply-To: json@yahoogroups.com
        >To: json@yahoogroups.com
        >Subject: Re: [json] json object from cookie
        >Date: Tue, 16 Jan 2007 17:18:28 -0800
        >
        >it is a basically a list with 3 elements. first is an empty string. the
        >next
        >two are list with each 2 elements.
        >this is what i got from mozilla firefox 2.0 show cookies option in
        >prefernces:
        >
        >"[\"\", [\"baby-boy|baby-boy_v\", \"baby-girl|baby-girl_v\"],
        >[\"lion|lion_v\", \"tiger|tiger_v\"]]"
        >
        >this is the cookie i set in python backend
        > >>> import cjson
        > >>> cjson.encode(["",['baby-boy|baby-boy_v',
        >'baby-girl|baby-girl_v'],['lion|lion_v', 'tiger|tiger_v']])
        >'["", ["baby-boy|baby-boy_v", "baby-girl|baby-girl_v"], ["lion|lion_v",
        >"tiger|tiger_v"]]'
        > >>>
        >
        >
        >thanks
        >mark
        >
        >
        >On 1/16/07, Mark Ireland <markincuba@...> wrote:
        > >
        > >
        > > Can we see the string?
        > >
        > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com>>
        > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
        > > >To: json@yahoogroups.com <json%40yahoogroups.com>
        > > >Subject: Re: [json] json object from cookie
        > > >Date: Mon, 15 Jan 2007 21:37:34 -0800
        > > >
        > > >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@...<markincuba%40hotmail.com>>
        > > wrote:
        > > > >
        > > > >
        > > > > What test do you do to show that your string is not a JSON object?
        > > > >
        > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
        > > rkmr.em%40gmail.com>>
        > > > > >Reply-To: json@yahoogroups.com
        ><json%40yahoogroups.com><json%40yahoogroups.com>
        > > > > >To: json@yahoogroups.com
        ><json%40yahoogroups.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]
        > > >
        > >
        > > __________________________________________________________
        > > Advertisement: It's simple! Sell your car for just $20 at
        >carsales.com.au
        > >
        > >
        >http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801577%2Fpi%5F1005244%2Fai%5F838588&_t=757768878&_r=endtext_simple&_m=EXT
        > >
        > >
        > >
        >
        >
        >[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
      • mark
        It definitely is a string, cos, when I try to access the list element [0], i just a character. mark ... [Non-text portions of this message have been removed]
        Message 3 of 13 , Jan 16, 2007
          It definitely is a string, cos, when I try to access the list element [0], i
          just a character.
          mark
          On 1/16/07, Mark Ireland <markincuba@...> wrote:
          >
          >
          > Could it be that the typeof() function just isnt that clever?
          >
          > '{' means - could be an object?
          >
          > anything else ie '[' that is definitely not an array - could be a string?
          >
          > >From: mark <rkmr.em@... <rkmr.em%40gmail.com>>
          > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
          > >To: json@yahoogroups.com <json%40yahoogroups.com>
          > >Subject: Re: [json] json object from cookie
          > >Date: Tue, 16 Jan 2007 17:18:28 -0800
          > >
          > >it is a basically a list with 3 elements. first is an empty string. the
          > >next
          > >two are list with each 2 elements.
          > >this is what i got from mozilla firefox 2.0 show cookies option in
          > >prefernces:
          > >
          > >"[\"\", [\"baby-boy|baby-boy_v\", \"baby-girl|baby-girl_v\"],
          > >[\"lion|lion_v\", \"tiger|tiger_v\"]]"
          > >
          > >this is the cookie i set in python backend
          > > >>> import cjson
          > > >>> cjson.encode(["",['baby-boy|baby-boy_v',
          > >'baby-girl|baby-girl_v'],['lion|lion_v', 'tiger|tiger_v']])
          > >'["", ["baby-boy|baby-boy_v", "baby-girl|baby-girl_v"], ["lion|lion_v",
          > >"tiger|tiger_v"]]'
          > > >>>
          > >
          > >
          > >thanks
          > >mark
          > >
          > >
          > >On 1/16/07, Mark Ireland <markincuba@...<markincuba%40hotmail.com>>
          > wrote:
          > > >
          > > >
          > > > Can we see the string?
          > > >
          > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
          > rkmr.em%40gmail.com>>
          > > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com><json%40yahoogroups.com>
          > > > >To: json@yahoogroups.com <json%40yahoogroups.com><json%40yahoogroups.com>
          > > > >Subject: Re: [json] json object from cookie
          > > > >Date: Mon, 15 Jan 2007 21:37:34 -0800
          > > > >
          > > > >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@... <markincuba%40hotmail.com>
          > <markincuba%40hotmail.com>>
          > > > wrote:
          > > > > >
          > > > > >
          > > > > > What test do you do to show that your string is not a JSON object?
          > > > > >
          > > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
          > rkmr.em%40gmail.com> <
          > > > rkmr.em%40gmail.com>>
          > > > > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
          > ><json%40yahoogroups.com><json%40yahoogroups.com>
          > > > > > >To: json@yahoogroups.com <json%40yahoogroups.com>
          > ><json%40yahoogroups.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]
          > > > >
          > > >
          > > > __________________________________________________________
          > > > Advertisement: It's simple! Sell your car for just $20 at
          > >carsales.com.au
          > > >
          > > >
          > >
          > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801577%2Fpi%5F1005244%2Fai%5F838588&_t=757768878&_r=endtext_simple&_m=EXT
          > > >
          > > >
          > > >
          > >
          > >
          > >[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]
        • Mark Ireland
          I think in terms of associative arrays, so maybe your cookie needs a key? ... _________________________________________________________________ Advertisement:
          Message 4 of 13 , Jan 17, 2007
            I think in terms of associative arrays, so maybe your cookie needs a key?

            >From: mark <rkmr.em@...>
            >Reply-To: json@yahoogroups.com
            >To: json@yahoogroups.com
            >Subject: Re: [json] json object from cookie
            >Date: Tue, 16 Jan 2007 21:36:54 -0800
            >
            >It definitely is a string, cos, when I try to access the list element [0],
            >i
            >just a character.
            >mark
            >On 1/16/07, Mark Ireland <markincuba@...> wrote:
            > >
            > >
            > > Could it be that the typeof() function just isnt that clever?
            > >
            > > '{' means - could be an object?
            > >
            > > anything else ie '[' that is definitely not an array - could be a
            >string?
            > >
            > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com>>
            > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
            > > >To: json@yahoogroups.com <json%40yahoogroups.com>
            > > >Subject: Re: [json] json object from cookie
            > > >Date: Tue, 16 Jan 2007 17:18:28 -0800
            > > >
            > > >it is a basically a list with 3 elements. first is an empty string. the
            > > >next
            > > >two are list with each 2 elements.
            > > >this is what i got from mozilla firefox 2.0 show cookies option in
            > > >prefernces:
            > > >
            > > >"[\"\", [\"baby-boy|baby-boy_v\", \"baby-girl|baby-girl_v\"],
            > > >[\"lion|lion_v\", \"tiger|tiger_v\"]]"
            > > >
            > > >this is the cookie i set in python backend
            > > > >>> import cjson
            > > > >>> cjson.encode(["",['baby-boy|baby-boy_v',
            > > >'baby-girl|baby-girl_v'],['lion|lion_v', 'tiger|tiger_v']])
            > > >'["", ["baby-boy|baby-boy_v", "baby-girl|baby-girl_v"], ["lion|lion_v",
            > > >"tiger|tiger_v"]]'
            > > > >>>
            > > >
            > > >
            > > >thanks
            > > >mark
            > > >
            > > >
            > > >On 1/16/07, Mark Ireland
            ><markincuba@...<markincuba%40hotmail.com>>
            > > wrote:
            > > > >
            > > > >
            > > > > Can we see the string?
            > > > >
            > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
            > > rkmr.em%40gmail.com>>
            > > > > >Reply-To: json@yahoogroups.com
            ><json%40yahoogroups.com><json%40yahoogroups.com>
            > > > > >To: json@yahoogroups.com
            ><json%40yahoogroups.com><json%40yahoogroups.com>
            > > > > >Subject: Re: [json] json object from cookie
            > > > > >Date: Mon, 15 Jan 2007 21:37:34 -0800
            > > > > >
            > > > > >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@... <markincuba%40hotmail.com>
            > > <markincuba%40hotmail.com>>
            > > > > wrote:
            > > > > > >
            > > > > > >
            > > > > > > What test do you do to show that your string is not a JSON
            >object?
            > > > > > >
            > > > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
            > > rkmr.em%40gmail.com> <
            > > > > rkmr.em%40gmail.com>>
            > > > > > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
            > > ><json%40yahoogroups.com><json%40yahoogroups.com>
            > > > > > > >To: json@yahoogroups.com <json%40yahoogroups.com>
            > > ><json%40yahoogroups.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]
            > > > > >
            > > > >
            > > > > __________________________________________________________
            > > > > Advertisement: It's simple! Sell your car for just $20 at
            > > >carsales.com.au
            > > > >
            > > > >
            > > >
            > >
            >http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801577%2Fpi%5F1005244%2Fai%5F838588&_t=757768878&_r=endtext_simple&_m=EXT
            > > > >
            > > > >
            > > > >
            > > >
            > > >
            > > >[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]
            >

            _________________________________________________________________
            Advertisement: Fresh jobs daily. Stop waiting for the newspaper. Search now!
            www.seek.com.au
            http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=757263760&_r=Hotmail_EndText_Dec06&_m=EXT
          • mark
            what do you mean by that? i set it with a key and retrieve it with the same key. ... [Non-text portions of this message have been removed]
            Message 5 of 13 , Jan 17, 2007
              what do you mean by that?
              i set it with a key and retrieve it with the same key.


              On 1/17/07, Mark Ireland <markincuba@...> wrote:
              >
              >
              > I think in terms of associative arrays, so maybe your cookie needs a key?
              >
              > >From: mark <rkmr.em@...>
              > >Reply-To: json@yahoogroups.com
              > >To: json@yahoogroups.com
              > >Subject: Re: [json] json object from cookie
              > >Date: Tue, 16 Jan 2007 21:36:54 -0800
              > >
              > >It definitely is a string, cos, when I try to access the list element
              > [0],
              > >i
              > >just a character.
              > >mark
              > >On 1/16/07, Mark Ireland <markincuba@...> wrote:
              > > >
              > > >
              > > > Could it be that the typeof() function just isnt that clever?
              > > >
              > > > '{' means - could be an object?
              > > >
              > > > anything else ie '[' that is definitely not an array - could be a
              > >string?
              > > >
              > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com>>
              > > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
              > > > >To: json@yahoogroups.com <json%40yahoogroups.com>
              > > > >Subject: Re: [json] json object from cookie
              > > > >Date: Tue, 16 Jan 2007 17:18:28 -0800
              > > > >
              > > > >it is a basically a list with 3 elements. first is an empty string.
              > the
              > > > >next
              > > > >two are list with each 2 elements.
              > > > >this is what i got from mozilla firefox 2.0 show cookies option in
              > > > >prefernces:
              > > > >
              > > > >"[\"\", [\"baby-boy|baby-boy_v\", \"baby-girl|baby-girl_v\"],
              > > > >[\"lion|lion_v\", \"tiger|tiger_v\"]]"
              > > > >
              > > > >this is the cookie i set in python backend
              > > > > >>> import cjson
              > > > > >>> cjson.encode(["",['baby-boy|baby-boy_v',
              > > > >'baby-girl|baby-girl_v'],['lion|lion_v', 'tiger|tiger_v']])
              > > > >'["", ["baby-boy|baby-boy_v", "baby-girl|baby-girl_v"],
              > ["lion|lion_v",
              > > > >"tiger|tiger_v"]]'
              > > > > >>>
              > > > >
              > > > >
              > > > >thanks
              > > > >mark
              > > > >
              > > > >
              > > > >On 1/16/07, Mark Ireland
              > ><markincuba@...<markincuba%40hotmail.com>>
              > > > wrote:
              > > > > >
              > > > > >
              > > > > > Can we see the string?
              > > > > >
              > > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
              > > > rkmr.em%40gmail.com>>
              > > > > > >Reply-To: json@yahoogroups.com
              > ><json%40yahoogroups.com><json%40yahoogroups.com>
              > > > > > >To: json@yahoogroups.com
              > ><json%40yahoogroups.com><json%40yahoogroups.com>
              > > > > > >Subject: Re: [json] json object from cookie
              > > > > > >Date: Mon, 15 Jan 2007 21:37:34 -0800
              > > > > > >
              > > > > > >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@... <markincuba%40hotmail.com>
              > > > <markincuba%40hotmail.com>>
              > > > > > wrote:
              > > > > > > >
              > > > > > > >
              > > > > > > > What test do you do to show that your string is not a JSON
              > >object?
              > > > > > > >
              > > > > > > > >From: mark <rkmr.em@... <rkmr.em%40gmail.com> <
              > > > rkmr.em%40gmail.com> <
              > > > > > rkmr.em%40gmail.com>>
              > > > > > > > >Reply-To: json@yahoogroups.com <json%40yahoogroups.com>
              > > > ><json%40yahoogroups.com><json%40yahoogroups.com>
              > > > > > > > >To: json@yahoogroups.com <json%40yahoogroups.com>
              > > > ><json%40yahoogroups.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]
              > > > > > >
              > > > > >
              > > > > > __________________________________________________________
              > > > > > Advertisement: It's simple! Sell your car for just $20 at
              > > > >carsales.com.au
              > > > > >
              > > > > >
              > > > >
              > > >
              > >
              > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801577%2Fpi%5F1005244%2Fai%5F838588&_t=757768878&_r=endtext_simple&_m=EXT
              > > > > >
              > > > > >
              > > > > >
              > > > >
              > > > >
              > > > >[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]
              > >
              >
              > _________________________________________________________________
              > Advertisement: Fresh jobs daily. Stop waiting for the newspaper. Search
              > now!
              > www.seek.com.au
              >
              > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau&_t=757263760&_r=Hotmail_EndText_Dec06&_m=EXT
              >
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              >
              >


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.
            »
            «