JSON there and back
EasyJSON and data3 min
Write a function jsonRoundTrip(user). It turns the object user into a JSON string and then parses that string back into a new object. Return { json, copy } with the string and the object made from it.
Examples
jsonRoundTrip({ name: 'John', age: 35 })Returns { json: '{"name":"John","age":35}', copy: { name: 'John', age: 35 } }
Loading the editor...
- Input
jsonRoundTrip({ name: 'John', age: 35 })Expected{ json: '{"name":"John","age":35}', copy: { name: 'John', age: 35 } } - copy equals user, but it is a different object
Hidden tests run on Submit