JSFiddle - React, Tailwind, and code Playground

by Alexander

JavaScript

console.clear();

var json = {};
Reflect.defineProperty(window, "magicJSON", {
  get: function() { return JSON.stringify(json) },
  set: function(v){ for(let k of Reflect.ownKeys(v)) json[k] = v[k] }
});

magicJSON = { foo: 123 };
magicJSON = { bar: [1,2,3] };
magicJSON = { buz: "abc" };
magicJSON = { obj: {a:1,b:2} };

console.log('string' == typeof magicJSON);
console.log(magicJSON);