Bookmark this: tool.io/matrix/as-json/source-code
Matrix as JSON Source Code
Browse the implementation files for Matrix as JSON.tool.ts typescript
import { matrixAsJson as formatPortableMatrixAsJson } from '@tool.io/tools/matrix/as-json';
export const matrixAsJson = (
input: unknown,
indentInput: unknown = '2'
): string => {
const indent = Number(indentInput);
return formatPortableMatrixAsJson(input, indent) ?? '';
};
export const Tool: TypeTool = {
name: 'Matrix as JSON',
slug: 'matrix/as-json',
intro: 'Convert a numeric matrix into a JSON array of rows.',
tool: matrixAsJson,
i: [
{
example: '1 2\n3 4',
label: 'Matrix',
placeholder: 'Enter a matrix',
render: 'textarea',
type: 'text'
},
{
example: '2',
label: 'Indentation',
options: [
{ text: 'Compact', value: '0' },
{ text: '2 spaces', value: '2' },
{ text: '4 spaces', value: '4' }
],
placeholder: 'Choose indentation',
type: 'select',
value: '2'
}
],
o: [
{
example:
'[\n [\n 1,\n 2\n ],\n [\n 3,\n 4\n ]\n]',
label: 'JSON',
placeholder: 'JSON will appear here...',
render: 'textarea',
type: 'text'
}
],
alternative: [
{ title: 'Numeric Matrix Parser', url: '/parse/matrix' }
]
};
export default Tool;
Description
Browse the implementation files for Matrix as JSON.