JSON

Parser

JSON path

JSON query and field selection

JSON schema

Media type with schema application/json;schema="http://example.com/my-hyper-schema#. See JSON Schema: A Media Type for Describing JSON Documents It's possible to use Link header with rel parameter instead. See JSON Schema: A Media Type for Describing JSON Documents

There is not inherance, but a validation rule (more like interfaces):

"allOf": [
	{
		"$ref": "#/definitions/some-object"
	},
	{
		"type": "object",
		"properties": {
			"specific-property": {
				"type": "number"
			}
		}
	}
]

Can be used to edit (with a dedicated UI) JSON and validate again a schema it with:

JSON Schema editors and validators:

Documentation:

See also

Data generator from schema:

Binary data

Base64, Base92, etc.

// Get list of available chars inside string that use 1 byte (last code point usable in UTF-8 is 0x7F https://en.wikipedia.org/wiki/UTF-8, ASCII 7bits only) and doesn't require JSON encoding
JSON.parse(JSON.stringify(String.fromCharCode(...Array.from({length: 0x7F + 1}, (value, index) => index))).replace(/\\(u[0-9a-z]{4,}|.)/gi, ""))
// Encode integer to include it in JSON string in first UTF-8 byte
function encode(value){
	value = Math.max(value, 0);// only unsigned value
	const charset = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~";
	const radix = charset.length;

	let s = "";
	do {
		s = charset.charAt(value % radix) + s;
		value = Math.floor(value / radix);
	} while(value >= 1)

	return s;
}

function decode (value) {
	// const charset = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"
	const charset = "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~";
	const radix = charset.length;

	let n = 0;
	for(let index = 0, length = value.length; index < length; index++){
		n += charset.indexOf(value.charAt(index)) * radix ** (length - 1 - index);
	}
	return n;
}

Comments

Comment syntax does not exist in JSON (like /* ... */ or // ...). Use a field for that, which could start with $, @, #, //, etc.

You should not use duplicated keys. It's could be supported by parser/writer but it's not standard.

Format used by JSON Schema:

{
	"$comment": "comment line 1\ncomment line 2"
}

Tools

Last updated