Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ajkachnic/jason

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ajkachnic/jason

`jason` is a JSON parser and formatter written in JavaScript. It's pretty simple (220 lines with comments and blank lines) and should be pretty fast. It uses [`moo`](https://github.com/no-context/moo) for lexing, and then iterates over that stream of toke

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

jason

jason is a JSON parser and formatter written in JavaScript. It's pretty simple (220 lines with comments and blank lines) and should be pretty fast. It uses moo for lexing, and then iterates over that stream of tokens. It supports proper strings, floats, and some pretty errors. It's kinda pointless because JSON.parse exists, but interesting nonetheless.

install

npm install @ajkachnic/jason

usage

You can selectively import the functions you want using destructuring

Here's a typescript example:

import { parse, format, beautify } from '@ajkachnic/jason'

And here's a commonjs version:

const { parse, format, beautify } = require('@ajkachnic/jason')

api

parse

parse takes a string and returns it's JavaScript equivalent.

Example:

const output = parse('{ "name": "bob", "age": 28.5 }') // { name: "bob", age: 28.5 }

format

format takes a JavaScript value and returns it's JSON encoded counterpart. Please only pass this things that will be properly encoded (class instances and stuff won't be)

It also has a second optional argument for whether or not to pretty-print. This is set to false by default

Example:

const json = format({ name: "bob", age: 28.5 }) // {"name":"bob","age":28.5}

beautify

beautify takes a JSON string and returns a pretty-printed version. It basically just parses it and then runs format on it with pretty printing enabled. It's probably not very fast

Example:

const beautified = beautify('{"name":"bob","age":28.5}') // { "name": "bob", "age": 28.5 }

FAQs

Package last updated on 31 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc