Publisher review:Marshalling Python Data into Javascript code creates a function, to_js, that marshals Python data into a Javascript string. Marshalling Python Data into Javascript code creates a function, to_js, that marshals Python data into a Javascript string.&lython data into a ;The to_js function supports Python integers, floats, mx.DateTime dates (if mx.DateTime can be imported), strings, None, sequences, and dictionaries.
It will complain loudly if you try to pass another type. The reliance on type rather than interface is rather unfortunate, in that Python classes that emulate the behavior of the builtin containers may not be their subclasses; with some database drivers, for instance, the result set returned for a row behaves a bit like a list and a bit like a dictionary, but is an instance of neither.
To marshal such an object with this code, you have to cast it first. The script could conceivably be refined by replacing the type checks for those containers with some other heuristic for determining whether an object is "close enough" to a list/tuple/dict.
Marshalling Python Data into Javascript 1.0 is a Python script for Internet, Browsers and Tools scripts design by Jacob Smullyan.
It runs on following operating system: Windows / Linux / Mac OS / BSD / Solaris.
Operating system:Windows / Linux / Mac OS / BSD / Solaris