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

jsoun

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsoun

Ever wanted to put json in a url and thought it was ugly? JSOUN (Javascript Object URL Notation) makes it slightly better

  • 0.1.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Ever wanted to put JSON in a url? It's ugly, right?

To make it slightly better, you can use JSOUN (Javascript Object URL Notation).

Example

var JSOUN = require('./index.js')

var obj = {
    "glossary": {
        "title": "example glossary",
		"GlossDiv": {
            "title": "S",
			"GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
					"SortAs": "SGML",
					"GlossTerm": "Standard Generalized Markup Language",
					"Acronym": "SGML",
					"Abbrev": "ISO 8879:1986",
					"GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
						"GlossSeeAlso": ["GML", "XML"]
                    },
					"GlossSee": "markup"
                }
            }
        }
    }
}

var ugly = encodeURI(JSON.stringify(obj))
var pretty = JSOUN.encode(obj)

console.log(ugly)
console.log('\n\n')
console.log(pretty)

Without JSOUN

%7B%22glossary%22:%7B%22title%22:%22example%20glossary%22,%22GlossDiv%22:%7B%22title%22:%22S%22,%22GlossList%22:%7B%22GlossEntry%22:%7B%22ID%22:%22SGML%22,%22SortAs%22:%22SGML%22,%22GlossTerm%22:%22Standard%20Generalized%20Markup%20Language%22,%22Acronym%22:%22SGML%22,%22Abbrev%22:%22ISO%208879:1986%22,%22GlossDef%22:%7B%22para%22:%22A%20meta-markup%20language,%20used%20to%20create%20markup%20languages%20such%20as%20DocBook.%22,%22GlossSeeAlso%22:%5B%22GML%22,%22XML%22%5D%7D,%22GlossSee%22:%22markup%22%7D%7D%7D%7D%7D

With JSOUN

('glossary':('title':'example_glossary','GlossDiv':('title':'S','GlossList':('GlossEntry':('ID':'SGML','SortAs':'SGML','GlossTerm':'Standard_Generalized_Markup_Language','Acronym':'SGML','Abbrev':'ISO_8879:1986','GlossDef':('para':'A_meta-markup_language,_used_to_create_markup_languages_such_as_DocBook.','GlossSeeAlso':~'GML','XML';),'GlossSee':'markup')))))

Note

JSOUN is only 100% safe in the fragment part of the url, i.e. after the # delimiter.

Keywords

FAQs

Package last updated on 11 Mar 2020

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