Data JSON - v0.1.0+alpha

Insert content extracted from a JSON file.

Data selection is done by an JSON Pointer URI Fragment as described in section 6 of RFC6901

The following attribute is supported:

data-json-after
Insert content after an element
data-json-append
Insert content at the end of an element
data-json-before
Insert content before an element
data-json-prepend
Insert content at the start of an element
data-json-replace
Replace content inside an element
data-json-replacewith
Replace an element by the content

Example

My product ABC cost (consult our fees schedule)

<p>My product ABC cost <a data-json-replacewith="data-en.json#/fees/ABC" href="#">(consult our fees schedule)</a></p>

Your are currently viewing the product "Unknown"

<p>Your are currently viewing the product &quot;<span data-json-replace="data-en.json#/products/en">Unknown</span>&quot;</p>

Content of data-en.json

{
	"fees": {
		"ABC": "20$"
	},
	"products": "Hello world"
}

Selecting data

(Source: JSON Pointer, RCF6901)

For example, given the JSON document

{
	"foo": ["bar", "baz"],
	"": 0,
	"a/b": 1,
	"c%d": 2,
	"e^f": 3,
	"g|h": 4,
	"i\\j": 5,
	"k\"l": 6,
	" ": 7,
	"m~n": 8
}

The following URI fragment identifiers evaluate to the accompanying values:

URI fragment Returning value
# The whole document
#/foo ["bar", "baz"]
#/foo/0 "bar"
#/ 0
#/a~1b 1
#/c%25d 2
#/e%5Ef 3
#/g%7Ch 4
#/i%5Cj 5
#/k%22l 6
#/%20 7
#/m~0n 8

Issue that you may encounter

Display nothing, plugin seems to be broken.
Ensure that your JSON file is valid
Recently updated data do not display
Refresh your browser cache by opening a new tab the JSON file and then do a hard refresh Ctrl + F5 or by testing your page from a new private mode session of your browser.
Date modified: