samirprogrammer
samirprogrammer

Reputation: 438

JSON.stringify is not working in blackberry mobile

JSON.stringify is not working in blackberry mobile it is working great in iphone and other browser. it is not prompting it in below example in blackberry mobile:

  function sup() {
        this.name;
    }

    var SUP = new sup();

        SUP.name = 'XYZ' ;
        var tt = JSON.stringify(SUP);
        alert(tt);

Upvotes: 0

Views: 304

Answers (2)

Claudio Redi
Claudio Redi

Reputation: 68440

You should create a fallback mechanism so browser uses the native JSON support if present, otherwise it download the library that @T.J. Crowder pointed out

Something like this should do the trick

<script>window.JSON|| 
    document.write("<script src='js/my-json-library.js'>\x3C/script>")
</script>

Upvotes: 1

T.J. Crowder
T.J. Crowder

Reputation: 1075567

It sounds like that version of the Blackberry browser doesn't support the new JSON object, which was introduced in ES5 (so, just recently). You can find several polyfills/shims, including ones from the "introducer" of JSON himself.

Upvotes: 1

Related Questions