• Stars
    star
    383
  • Rank 111,995 (Top 3 %)
  • Language
    JavaScript
  • Created about 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

URL-friendly JSON

JSURL

JSURL is an alternative to JSON + URL encoding (or JSON + base64 encoding). It makes it handy to pass complex values via URL query parameters.

JSURL has been designed to be:

  • Compact: its output is much more compact than JSON + URL encoding (except in pathological cases). It is even often slightly more compact than regular JSON!
  • Readable: its output is much more readable than JSON + URL encoding.
  • Foolproof: its output only contains characters that are unaffected by URL encoding/decoding. There is no risk of missing a URL encoding/decoding pass, or of messing up a JSURL string by applying an extra URL encoding or decoding pass.
  • Easy to generate and parse

Syntax

Think of it as JSON with the following changes:

  • Curly braces ({ and }) replaced by parentheses (( and ))
  • Square brackets ([ and ]) replaced by (~ and )
  • Property names unquoted (but escaped -- see below).
  • String values prefixed by a single quote (') and escaped
  • All other JSON punctuation (colon : and comma ,) replaced by tildes (~)
  • An extra tilde (~) at the very beginning.

Property names and string values are escaped as follows:

  • Letters, digits, underscore (_), hyphen (-) and dot (.) are preserved.
  • Dollar sign ($) is replaced by exclamation mark (!)
  • Other characters with UNICODE value <= 0xff are encoded as *XX
  • Characters with UNICODE value > 0xff are encoded as **XXXX

Examples

JSON:

{"name":"John Doe","age":42,"children":["Mary","Bill"]}

JSON + URL encoding:

%7B%22name%22%3A%22John%20Doe%22%2C%22age%22%3A42%2C%22children%22%3A%5B%22Mary%22%2C%22Bill%22%5D%7D

JSURL:

~(name~'John*20Doe~age~42~children~(~'Mary~'Bill))

API

var JSURL = require("jsurl");

str = JSURL.stringify(obj);
obj = JSURL.parse(str);

// return def instead of throwing on error
obj = JSURL.tryParse(str[, def]);

Installation

The easiest way to install jsurl is with NPM:

npm install jsurl

License

This work is licensed under the MIT license.

More Repositories

1

streamlinejs

Asynchronous JavaScript for dummies
JavaScript
961
star
2

carbon

Carbon by Sage | ReactJS UI Component Library
TypeScript
278
star
3

ez-streams

Easy streams for node.js
TypeScript
44
star
4

sageone_api_php_sample

Sage One API PHP Sample
PHP
43
star
5

omniauth-cognito-idp

OmniAuth Strategy for AWS Cognito in Ruby
Ruby
35
star
6

SDataCSharpClientLib

SData .NET Client Library, written in C#, based on Microsoft Argotic
C#
33
star
7

SData-2.0

Contains documents pertaining to the SData 2.0 developments
33
star
8

SDataJavaScriptClientLib

Client library in JavaScript for consuming SData web services. Also, an HTML/CSS/JavaScript Mobile application framework.
JavaScript
29
star
9

argos-sdk

Framework for creating mobile SData clients using HTML5, JavaScript and CSS
JavaScript
28
star
10

fudge

A tool for enforcing code coverage and documentation in continuous integration.
Ruby
26
star
11

f-promise

Promise-oriented coroutines for node.js
TypeScript
22
star
12

i18n_yaml_editor

I18n Yaml Editor makes it easy to translate your Rails I18N files and keep them up to date
Ruby
21
star
13

yaml_normalizer

Yaml Normalizer - a Psych-based YAML checker and normalizer written in Ruby
Ruby
19
star
14

sageone_api_csharp_sample

Sage One API - C# Sample
C#
16
star
15

Sage-Live-Public-Wiki

16
star
16

sageone_br_nfe_documentacao_api

Documentação para a API do Sage One BR
15
star
17

SData-Contracts

Common SData Contracts
C#
14
star
18

sageone_api_ruby_sample

Sage Accounting API Ruby Sample Application
Ruby
10
star
19

design-tokens

Design tokens for the Sage Design system using Amazon Style Dictionary.
JavaScript
10
star
20

sinject

A simple dependency injection framework for ruby.
Ruby
9
star
21

f-streams

node.js streams with promises and coroutines
TypeScript
8
star
22

streamline-flamegraph

JavaScript
8
star
23

create-carbon-app

Quickly create a ready-for-dev application that uses React & Carbon.
JavaScript
7
star
24

TrustFabric

6
star
25

carbon-factory

CLI Toolkit for Carbon
JavaScript
6
star
26

sdata-downloads

6
star
27

sageone_api_java_sample

Sage One API - Java Sample
Java
5
star
28

eventq

Ruby
5
star
29

sageone_api_spring_sample

Sage One API Spring Sample
Java
4
star
30

sage_crm_rest_api_client

C#
3
star
31

grape_documenter

Adds a task to Rails applications to generate documentation for Grape APIs
Ruby
3
star
32

streamline-require

Client side require infrastructure built with (and for) streamline
JavaScript
3
star
33

sublime-x3

Sublime Text goodies for Sage ERP X3
3
star
34

x3-stock-graphql-demo

TypeScript
3
star
35

dotnet-coding-challenge

Sage .NET Core candidate interview challenge
C#
3
star
36

rake_helper

A set of common helper methods to DRY up Rails rake tasks
Ruby
3
star
37

streamline-streams

Simple streams API for streamline.js
JavaScript
2
star
38

dotnet-coding-challenge-3

C#
2
star
39

carbon-codemod

A collection of codemods to help you upgrade carbon-react
JavaScript
2
star
40

carbon-state-management

JavaScript
2
star
41

streamline-fs

JavaScript
2
star
42

streamline-runtime

streamline.js runtime
JavaScript
2
star
43

vat_id_validator

Ruby
2
star
44

device_wizard

A fast & light weight device detection framework.
Ruby
2
star
45

sageone_api_ruby_sdk

Sage One API - Ruby SDK
Ruby
2
star
46

rubocop-custom-cops

Custom checks for Rubocop - Static code analysis
Ruby
1
star
47

sageone_api_signer

Ruby
1
star
48

babel-plugin-streamline

Babel plugin for streamline.js
JavaScript
1
star
49

future_makers

Code Examples for Sage Future Makers Labs
Python
1
star
50

lazy_mock

LazyMock object which responds to EVERYTHING quite happily without complaint
Ruby
1
star
51

carbon-coding-challenge

JavaScript
1
star
52

validation_profiler

Ruby
1
star
53

argos

Web site repository for the "argos" mobile framework ecosystem. Links to code repositories, getting started guide, and more...
JavaScript
1
star
54

f-mocha

Mocha wrapper for f-promise
TypeScript
1
star
55

class_kit

Ruby
1
star
56

carbon-graveyard

All components and modules in this repository are no longer actively maintained, but are available for use if your application heavily relies on them.
Shell
1
star
57

dynamodb_framework

Ruby
1
star
58

cache_store

This is a cache framework base that includes a basic in memory cache store, along with a dependency contract for additional provider implementations to follow.
Ruby
1
star
59

mysql_framework

Ruby
1
star
60

argos-template

Creating a new argos mobile application from scratch? Start with this template and use our Getting Started guide (coming soon).
ASP
1
star