JSON Playlists


A JSON playlist is a text-based structure that is more compact than XML.

While JSON may look like Javascript, it is still text-based. Meaning that it is "dumb" text and not "live" Javascript code.   See "JSON & Javascript Differences" for more information.

Refer to the Track Dataset page for details on the information that can be included for each item.

NOTE: If you're not familiar with JSON, click here for a brief introduction to JSON.

The Wimpy JSON Format is structured as follows:

		"file"  : "track1.mp3",
		"title" : "Track 1",
		"image" : "coverart.jpg"
		"file"  : "track2.mp3",
		"title" : "Track 2",
		"image" : "coverart.jpg"
		"file"  : "track3.mp3",
		"title" : "Track 3",
		"image" : "coverart.jpg"

Where the square brackets define the "list" and individual "items" are represented within curly brackets.

Each "item" is separated by a comma.

[ item, item, item ]

Again, details on what can be included in the data set are explained in detail on the Track Dataset page.


Loading a JSON playlist into the player

To load an external JSON playlist file, simply set "data-media" to the URL to the JSON file.

<div data-wimpyplayer data-media="path/to/playlist.json"></div>


NOTE: The JSON file does NOT have to have the "json" extension, the extension can be whatever you want. (e.g. "txt")


You can also load JSON data directly into the "data-media" option:

<div data-wimpyplayer data-media='[{"file":"track1.mp3","title":"Track 1","image":"coverart.jpg"},
{"file":"track2.mp3","title":"Track 2","image":"coverart.jpg"},
{"file":"track3.mp3","title":"Track 3","image":"coverart.jpg"}]'></div>

NOTE: Line breaks were added to the JSON data above for sanity's sake. Newline's should be removed for testing.

Since JSON requires double quotes around keys and string, the entire JSON block must be wrapped with single-quotes. If the content within the JSON block contains a single quote, the single quotes must be "escaped" using either HTML entities or the backslash.

See Also

- Track Dataset
- JSON & Javascript Differences
- Playlists Within Playlists