Oh and documentation says that it will return false if it can parse it, but
exception is always thrown :)
2008/7/2 petr kobalicek <[EMAIL PROTECTED]>:
> Hi again :)
>
> I have problem with qx.io.Json.parse()
>
> qx.io.Json.parse('{"result": {"files": [["AUTOEXEC.BAT", 0,
> "source\/batch", "", ""], ["boot.ini", 250, "document\/ini", "", ""],
> ["Bootfont.bin", 4952, "", "", ""], ["bootsect.lnx", 512, "", "", ""],
> ["CONFIG.SYS", 0, "windows\/system-file", "", ""], ["IO.SYS", 0,
> "windows\/system-file", "", ""], ["MSDOS.SYS", 0, "windows\/system-file",
> "", ""], ["NTDETECT.COM", 47564, "windows\/executable", "", ""], ["ntldr",
> 250048, "", "", ""]], "dirs": ["..", "cygwin", "Documents and Settings",
> "Download", "Games", "MSOCache", "My", "Program Files", "RECYCLER",
> "School", "Shared", "System Volume Information", "Upload", "WINDOWS"],
> "path": "\/"}}');
>
> This JSON string was generated by python simplejson package and I thing
> that's correct. If I use eval, everything is ok.
>
> Where is the problem ?
>
> NOTE: qooxdoo version 0.7.3, firefox3, ie7
>
> Error: Could not parse JSON string!
>
> Source code of parse()
>
> /**
> * Parse a JSON text, producing a JavaScript value.
> * It returns false if there is a syntax error.
> *
> * @type static
> * @param text {String} JSON string
> * @return {Object} Returns the object
> * @throws an error if the text could not be parsed or evaluated
> */
> parse : function(text)
> {
> // here is something wrong ?
> if (!(/[^,:{}\[\]0-9.\-+Eaeflnr-u
> \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, "")))) {
> throw new Error("Could not parse JSON string!");
> }
>
> try {
> return eval("(" + text + ")");
> } catch(ex) {
> throw new Error("Could not evaluate JSON string: " + ex.message);
> }
> },
>
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel