On this page
Β§ Getting Started
Get started with jsonx by following the steps below.
Β§ Install
Install as usual via NPM:
npx jsr add @fartlabs/jsonx
Or if youβre using Deno:
deno add @fartlabs/jsonx
Add the following values to your deno.json(c) file.
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@fartlabs/jsonx"
}
}
Β§ Use
Add a file ending in .[j|t]sx to your project. For example, example.tsx.
function Cat() {
return { animals: ["π"] };
}
function Dog() {
return { animals: ["π"] };
}
const data = (
<>
<Cat />
<Dog />
</>
);
Deno.writeTextFileSync(
"data.json",
JSON.stringify(data, null, 2),
);
Compile your jsonx by running the .[j|t]sx file.
deno run --allow-write example.tsx
Preview the data.json file.
cat data.json
Resulting data.json:
{
"animals": [
"π",
"π"
]
}
Learn more about JSX.