This project is archived and is in readonly mode.

#706 ✓invalid
emilime

JSON request with ContentType json-comment-filtered

Reported by emilime | July 7th, 2009 @ 03:44 PM | in 2.0 (closed)

I'm trying to use Request.JSON with a server that returns data as application/json-comment-filtered, a string formatted in this way:

application/json-comment-filtered: ’/[ASTERISK]{ msg: 'bla bla bla' }[ASTERISK]/’

([ASTERISK] is the character)

Mootools JSON.decode is unable to parse this string and translate it to an object, so I get responseJSON as null object.

Comments and changes to this ticket

  • Fábio M. Costa

    Fábio M. Costa July 8th, 2009 @ 12:57 AM

    its not a corret JSON.
    Or you correct your server, or you can use Request() and us the JSON.decode including the string without [ASTERISK] around it.
    This is not a Mootools issue.
    Try asking these questions on the mail list first:

    http://groups.google.com/group/mootools-users

    I'm just saying, not being rude (it might looked like, but i'm not).

  • emilime

    emilime July 8th, 2009 @ 09:13 AM

    no problem Fabio, I was not sure that it was the right place, I'all ask to google user group next time.
    Thanks for the answer

  • Sebastian Markbåge

    Sebastian Markbåge July 8th, 2009 @ 02:05 PM

    • Tag changed from json to json, security
    • State changed from “new” to “open”
    • Assigned user set to “Sebastian Markbåge”

    This is a valid feature request. It's a pretty solid workaround to prevent cross site scripting in older browsers.

    It will need some discussion though. application/json-comment-filtered isn't a ubiquitous standard. It's introduced by specifically by Dojo. There are various other formats as well.

  • Fábio M. Costa

    Fábio M. Costa July 9th, 2009 @ 01:00 AM

    Thank you Sebastian.
    I dindt know about that, sorry for trying to answer questions i dont know the answer :S

  • emilime

    emilime July 9th, 2009 @ 11:20 AM

    Thanks Sebastian, I'm happy yuo have accepted this as a valid feature request, I think it would be useful to give Mootools greater compatibility.

  • Sebastian Markbåge

    Sebastian Markbåge July 11th, 2009 @ 08:05 PM

    • State changed from “open” to “invalid”

    So, after some consideration, I think that using POST requests is the most appropriate solution to avoid cross-site request forgery for JSON data. Since there are no ubiquitous alternative format we shouldn't include it in Core.

    However, support for a few alternative formats might make a good addition to MooTools More. Such as when you don't have control over the server implementation for some reason.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Tags

Pages