1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,393
    Vote Rating
    175
    Answers
    13
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default Answered: Why Ext.USE_NATIVE_JSON is false by default?

    Answered: Why Ext.USE_NATIVE_JSON is false by default?


    Why Ext.USE_NATIVE_JSON is false by default?

    Native JSON parsing is faster and more secure because it will not compile scripts.

  2. Legacy, mostly. There's a whole lot of code that works fine with:

    Code:
    {
        data: [{
            name: 'foo'
        }]
    }
    Then suddenly it all explodes. Most certainly it's better to use the native JSON, but it's off by default for the purposes of backwards compatibility.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    685
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Here is a previous thread that discusses this a little:
    http://www.sencha.com/forum/showthread.php?73110

    Scott.

  4. #3
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,393
    Vote Rating
    175
    Answers
    13
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    Thanks Scott, but this is a very old thread.

    You should try to parse using the native JSON parser first.

    Even jQuery is doing that

  5. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,154
    Vote Rating
    475
    Answers
    685
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I will shoot this over to one of the senior developers so we can both find out

    Scott.

  6. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,046
    Vote Rating
    657
    Answers
    471
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Legacy, mostly. There's a whole lot of code that works fine with:

    Code:
    {
        data: [{
            name: 'foo'
        }]
    }
    Then suddenly it all explodes. Most certainly it's better to use the native JSON, but it's off by default for the purposes of backwards compatibility.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #6
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    52
    Vote Rating
    3
    extjs@kingsquare.nl is on a distinguished road

      0  

    Default


    There are more issues with the current default (eval-based) approach. E.g. \u2028 and \u2029 characters can not be decoded using eval since they are not valid in a string, but work fine with JSON.parse.

    Try in your console for example:

    var a = {"test": "
this"};

    You will see JavaScript throws an error, since the word "this" contains such a character. However, when this would be received through AJAX (and not as a string literal), it could perfectly fine be decoded through JSON.parse.