Skip to content

Standalone library that pretty prints your JSON documents in the browser.

License

Notifications You must be signed in to change notification settings

dovy/jsonview-standalone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSONView-Standalone

This is a port of JSONView

It was made to be a standalone script. All you need to do is pass in an empty tag with id, and proper json will be formatted for the contents if the contents are indeed valid JSON.

Give index.html a try inside /src.

All that's needed is on load, to provide the ID or class of the item like so:

	window.onload = function() {
		// On load, run the code on the jsonId div. Pass in any id.
		// # denotes id, . denotes class
		jsonView('#jsonId');
	}

The div will be populated with pretty code.

One note, do not have any other attributes attached to the id. Class, div, etc. It will mess up the data. This is javascript library independent.


JSONView is a Firefox extension that helps you view JSON documents in the browser.

Normally when encountering a JSON document (content type "application/json"), Firefox simply prompts you to download the view. With the JSONView extension, JSON documents are shown in the browser similar to how XML documents are shown. The document is formatted, highlighted, and arrays and objects can be collapsed. Even if the JSON document contains errors, JSONView will still show the raw text.

Once you've got JSONView installed, check out this example JSON file to see the extension in action!

CouchDB users and others who need to have "application/json" sent in the HTTP Accept header to serve JSON properly should set that option in JSONView's options panel. Be aware that telling sites that you accept JSON can mess up some sites that don't expect it.

If you'd like to contribute to JSONView but don't want to code, consider contributing a translation. Just go to BabelZilla and register as a translator for the JSONView extension. There's not much there to translate!

Reporting Issues

Use the GitHub Issue tracker for JSONView to file issues. Pull requests are especially welcome.

Building JSONView

  • Install ant
  • Run ant to produce an XPI

Developing JSONView

Unofficial Ports

Common Issues

  • JSONView isn't displaying my file as JSON: You are probably not serving the JSON with the "application/json" MIME type.
  • JSONView is mangling large numbers: Here's the explanation.

JSONView is open source software under the MIT licence.

About

Standalone library that pretty prints your JSON documents in the browser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 92.4%
  • CSS 7.6%