npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ogson

v0.1.1

Published

The Original Gangster's Object Notation

Downloads

11

Readme

OGSON - Original Gangster Object Notation

In 2008, I invented a shittier version of JSON. This module is a functional version of the original implementation I created. I've tried to faithfully recreate the syntax, bugs and oddities of the format I invented back then before, apparently, I knew how to Google things.

Usage

npm install --save ogson

Convert a JavaScript object to OGSON:

'use strict';

const og = require('ogson');

let ogString = og.serialize({
  foo: 'bar'
});

console.log(ogString);

Turn a OGSON string into an object:

'use strict';

const og = require('ogson');

let ogString = '###@@@foo!!!@@@bar!!!^^^';
let ogObject = og.makeObject(ogString);

console.log(ogObject);

OGSON Features

Much like the better, more feature-rich JSON, I invented the OGSON format (which didn't have a name then) to provide a data transport format that more closely modeled the objects I was working with than XML. Here's what it could do.

Values

At the core of OGSON were values, begun by @@@ character sequences and ended by !!! sequences. Values were used as members of arrays and keys/values for hashes (see below).

@@@some value!!!

OGSON would try to guess the type of value inside the @@@ and !!! characters:

  • First, we check if it's an Array or Object (see below)
  • Next, we convert it into a Boolean if it's the text "true" or "false" (case insensitive)
  • Next, we'll try and parse it into a Number
  • Finally, we'll assume it's a String if all else fails

Arrays

Oh, you better believe we got those. Opened and closed by a [[[ and ]]] sequence respectively, values could be added in between them.

[[[
  @@@foo!!!
  @@@bar!!!
  @@@baz!!!
]]]

Objects

Yup, we got 'em! Denoted by a start character set of ### and an end set of ^^^, you could create a key/value object. Properties and values were denoted with @@@ / !!! patterns as you might expect.

###
  @@@foo!!! @@@bar!!!
^^^

Complex Objects

All these different types could be combined (usually) to model complex objects.

###
  @@@name!!! @@@ogson!!!
  @@@version!!! @@@1.0.0!!!
  @@@scripts!!! @@@###
    @@@test!!! @@@node test.js!!!
  ^^^!!!
  @@@keywords!!! @@@[[[
    @@@object!!!
    @@@notation!!!
    @@@wheel!!!
    @@@reinventing!!!
  ]]]!!!
^^^

Comments!

Put that in your pipe and smoke it, Crockford! Thanks to the half-assed parsing logic of OGSON, Comments are supported as free text just about anywhere... so long as they don't use the magic character sequences incorrectly.

In fact, so long as you don't run afoul of the magic character sequences, you can get pretty creative with your formatting.

This is a package.json converted to OGSON
###
  Here's the name of the package
  @@@name!!! => @@@ogson!!!

  We specify the version here
  @@@version!!! -> @@@1.0.0!!!

  These are npm run scripts - you can run the tests with "npm test"
  @@@scripts!!! ¯\_(ツ)_/¯ @@@###
    @@@test!!! @@@node test.js!!!
  ^^^!!!

  Keywords, yo!
  @@@keywords!!! @@@[[[
    * @@@object!!!          Objects!
    * @@@notation!!!        Notation!
    * @@@wheel!!!           Wheels!
    * @@@reinventing!!!     Reinventing!
  ]]]!!!
^^^

Creative Constraints

You don't want to represent EVERY kind of data, do you? Here are some things the original (and this iteration of) OGSON can't do:

  • Escape magic character sequences
  • Nest objects beyond one level
  • Represent the values "true", "false", or any parseable Number as a String
  • Probably lots of other stuff

License

MIT - as if you would want this code for any reason.