The JavaScript Object Notation (JSON) is meant exactly for this purpose.
JSON is in fact a subset of JavaScript, and modern browsers now
include a specific API for parsing and generating it
(https://developer.mozilla.org/En/Using_native_JSON ).
Python likewise has a JSON module in the std lib:
http://docs.python.org/library/json.html
> OR
> 2)
>>> import array
>>> y = array.array(i, L)
> then return y to javascript function
> But the problem with this method is, it will give an array of basic values
> only.
The word "array" gets tossed around a lot by programmers. The `array`
module is not at all what you want in this case.
Cheers,
Chris
--
http://rebertia.com
http://pypi.python.org/pypi/simplejson/
Cheers,
Chris
It takes a *string* containing JSON. You want:
var ctg = JSON.parse('["A", "B", "C"]');// note outer quotes!
Think about it: If you already had ["A", "B", "C"] in the first place,
then you could just do:
var ctg = ["A", "B", "C"];
And JSON would never enter into the discussion.
Your issue is akin to confusing the following two outputs:
Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'foo' # expression resulting in the string
'foo'
>>> print 'foo' # contents of the string
foo
Regards,
Chris