summerstyle / jsontreeviewer Goto Github PK
View Code? Open in Web Editor NEWjson formatter/viewer/pretty-printer (with jsonTree javascript-library)
Home Page: http://summerstyle.github.io/jsonTreeViewer
License: MIT License
json formatter/viewer/pretty-printer (with jsonTree javascript-library)
Home Page: http://summerstyle.github.io/jsonTreeViewer
License: MIT License
this is not a bug, but a contribution.
I made an angularjs directive for this.
.directive('jsonTree', function () {
return {
restrict: 'EA',
scope: {
data: '=',
expandall: '&',
collapseall: '&'
},
template: '<div></div>',
link: function ($scope, element, attrs) {
var tree;
tree = jsonTree.create($scope.data, element[0]);
}
}
});
html syntax:
<div json-tree data="inspector.reqbody">Invalid json-data, check RAW format</div>
data is the json object.
obviously collapseall and expandall functionality is not there yet, but this is a good starting point
The readme has no mention of the findAndHandle method, and what the matcher, or handler functions need to be, or contain.
Could you provide some example or definition for that? Thanks
This control would be particularly useful for developers. Developers are power users. Developers get annoyed when the values that they're working with have to be typed out manually instead of copied and pasted.
Just a suggestion, I dont know how to make it on github. When you want to open up to a certain level, it's not the number of children that counts, it's the number of parents. There should be something the developper could write like this:
tree.expand(function(node) {
return node.parents.length < depth;
}
Here's a working thing that you can easily include in your source code like parents() with a "s" or something:
var get_nb_parents = function(node) {
var n = node,
retour = 0;
while (n.parent !== null) {
n = n.parent;
retour++
}
return retour;
};
tree.expand(function (node) {
return get_nb_parents(node) < max_level;
});
и сделать возможным отображение ТОЛЬКО ключей?
new Function
root["phoneNumbers"]["0"]["type"]
)with http://summerstyle.github.io/jsonTreeViewer#<url>
jsonTree.js will print out HTML content to the page as is rather than escaping the HTML entities. This results in the HTML being inserted into the DOM and presented, and allows some types of custom Javascript execution. This constitutes an XSS vulnerability for any pages that render user-provided JSON using this library.
For example, on your demo page at http://summerstyle.github.io/jsonTreeViewer/ - provide the input {"test":"<img src='x' onerror='alert(1)'>"}
and observe the alert.
how to work with dynamic div element to load the jsonview? It gives domEl error
Недавно установила это прекрасное расширение для лисы https://addons.mozilla.org/es/firefox/addon/json-dataview/
В нем используется моя библиотека, но был сделан ряд улучшений.
Хочу добавить этот функционал в саму библиотеку.
url
, типа 'строка' и начинающаяся с префикса http://
- это подтип 'ссылка' с соотв. шаблоном для вывода (с тегом <a>
и подчеркнутая)А также, идеи для редактора:
CSS:
JS constructors:
Your expand function wasn't 100% working. Here's a working version of your expand Tree function:
/**
* Expands all tree nodes (objects or arrays) recursively
*
* @param {Function | undefined} filterFunc - 'true' if this node should be expanded
* @param {Object | undefined} node - starting node if precised
*/
expand : function(filterFunc, node) {
var self = this,
n = (typeof(node) === 'undefined' ? this.rootNode : node);
if (!n.isComplex) {
return;
}
if (typeof(filterFunc) === 'function') {
if (filterFunc(n)) {
n.expand();
n.childNodes.forEach(function(item) {
self.expand(filterFunc, item);
});
} else {
n.collapse();
}
} else {
n.expand();
n.childNodes.forEach(function(item) {
self.expand(filterFunc, item);
});
}
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.