const matrix = new DOMMatrixReadOnly("translate(20px, 30px)");
const matrix3D = new DOMMatrixReadOnly("translate3d(22px, 55px, 66px)");
const json = matrix.toJSON();
console.log(json); // A plain object
console.log(typeof json); // "object"
console.log(json.is2D); // Same value as matrix.is2DDOMMatrixReadOnly: toJSON() method / notebook
DOMMatrixReadOnly: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
console.log(JSON.stringify(matrix));console.log(JSON.stringify(matrix3D));