Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# JSONView-for-Chrome

JSONView-for-Chrome is an extension of chrome created by [gildas-lormeau](https://github.com/gildas-lormeau/JSONView-for-Chrome)
which is very useful for people who deals a lot with json type http requests.

But sometimes we would like to handle with our own json data, not from the internet. So I added a json editor to this extension
to make it more handful. The json editor is copied from [josdejong's jsoneditor](https://github.com/josdejong/jsoneditor).
7 changes: 7 additions & 0 deletions WebContent/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,10 @@ if (!localStorage.theme)
});
else
init();

// click on browser action
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({
url: chrome.extension.getURL("viewer/index.html")
});
});
4 changes: 4 additions & 0 deletions WebContent/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"version": "0.0.32.2",
"description": "Validate and view JSON documents",
"options_page": "options.html",
"browser_action": {
"default_icon" : "jsonview16.png",
"default_title" : "JSONView"
},
"background" : {
"scripts": [
"background.js"
Expand Down
39 changes: 39 additions & 0 deletions WebContent/viewer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE HTML>
<html>
<head>
<title>JSONEditor | Switch mode</title>

<!-- when using the mode "code", it's important to specify charset utf-8 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

<link href="jsoneditor/jsoneditor.min.css" rel="stylesheet" type="text/css">
<script src="jsoneditor/jsoneditor.min.js"></script>

<style type="text/css">
.container {
font: 10.5pt arial;
color: #4d4d4d;
line-height: 150%;
width: 980px;
margin: 0 auto;
}

#jsoneditor {
width: 960px;
height: 480px;
margin: 0 auto;
}
</style>
</head>

<body>
<div class="container">
<p>
You can paste the json data into `Text View` and change the view mode to see the effects. Enjoy it!
Powered by <a target="_blank" href="https://github.com/josdejong/jsoneditor">josdejong's jsoneditor</a>.
</p>
<div id="jsoneditor"></div>
</div>
<script src="viewer.js"></script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions WebContent/viewer/jsoneditor/jsoneditor.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions WebContent/viewer/jsoneditor/jsoneditor.min.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions WebContent/viewer/viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var container = document.getElementById('jsoneditor');

var options = {
mode: 'text',
modes: ['code', 'text', 'view'], // allowed modes
error: function (err) {
alert(err.toString());
}
};

var json = {
"array": [1, 2, 3],
"boolean": true,
"null": null,
"number": 123,
"object": {"a": "b", "c": "d"},
"string": "Hello World"
};

var editor = new JSONEditor(container, options, json);