Skip to main content
Home
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
64%
Published
a year ago (0.2.0)

jsonup

https://jsr.io/@tani/jsonup

This is a zero dependency compile-time JSON parser written in TypeScript.

Usage

import { JSONUP, ObjectLike } from 'jsonup' // Node
import { JSONUP, ObjectLike } from 'jsr:@tani/jsonup' // Deno

const src = `{ "name": "jsonup" }`

type Str = typeof src      // Type: `'{ "name": "jsonup" }'`
type Obj = ObjectLike<Str> // Type: `{ name: string }`

/**
 * JSONUP.parse infers the type from a given object.
 * The type parameter is optional.
 */
// Type: `{ name: string }` the inferred record type
// Value: `{ name: "jsonup" }` the generated object
let obj = JSONUP.parse(src) 
let obj = JSONUP.parse<Obj>(src)

/**
 * JSONUP.stringify guarantees the semantic equality between 
 * the generated string and the given literal type. 
 * The type parameter is required (maybe).
 */
// Type: `'{ "name": "jsonup" }'` the given literal type
// Value: `'{ "name": "jsonup" }'` the generated string
const str = JSONUP.stringify<Str>(obj) 

(c) 2022 TANIGUCHI Masaya. https://git.io/mit-license

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";
or

Import directly with a jsr specifier

import * as jsonup from "jsr:@tani/jsonup";

Add Package

pnpm i jsr:@tani/jsonup
or (using pnpm 10.8 or older)
pnpm dlx jsr add @tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";

Add Package

yarn add jsr:@tani/jsonup
or (using Yarn 4.8 or older)
yarn dlx jsr add @tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";

Add Package

vlt install jsr:@tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";

Add Package

npx jsr add @tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";

Add Package

bunx jsr add @tani/jsonup

Import symbol

import * as jsonup from "@tani/jsonup";