# JS-Interpreter JSON Demo

Moving primitive values (numbers, strings, booleans, etc) in and out of the interpreter is easy, they may be passed back and forth in function calls. By contrast, moving objects in and out of the interpreter is not advised. Having two JavaScript environments with handles to the same mutable JS object would be problematic. As a result, the best way to move objects (including arrays) in and out of the interpreter is to serialize and deserialize them as JSON. Below is a minimal example of round-tripping a JSON object though the interpreter and back.

Click Parse, then either click Step repeatedly, or click Run once. Open your browser's console for errors.

var data = JSON.parse(getInput()); alert(Object.keys(data)); setOutput(JSON.stringify(data));

JSON Input:

JSON Output:

Back to the JS-Interpreter documentation.