JSFiddle - React, Tailwind, and code Playground

by David Buzatto

JavaScript

// just a regular object
var obj = {
    a: "aaa",
    b: "bbb",
    c: function() {
        return this.a;
    }
};

console.log( obj.c() ); // prints "aaa"

// isn't it json just because it has a function? ExtJS will treat it like JSON, but jQuery not
var json = "{" +
    "\"a\": \"aaa\", " +
    "\"b\": \"bbb\", " +
    "\"c\": function() {" +
    "    return this.a;" +
    "}" +
"}";

// ok, the "json" above
console.log( json );

//var jsonObj = $.parseJSON( json ); // does not work
//var jsonObj = eval( json ); // does not work too
var jsonObj = Ext.decode( json ); // it works! shortcut for Ext.JSON.decode

console.log( jsonObj.c() );       // prints "aaa"