简体   繁体   中英

Parsing arbitrary json with json2html

Does anybody know of detailed api-level docs for json2html? I crawled through their webpage and found very little documentation.

Basically, I would like to take arbitrary json, and turn it into pretty html much like the "json visualizer" example on the json2html webpage, but the webpage doesn't event state if the visualizer is part of json2html lib or if its something else entirely.

A second question:

In their example they have the following transform:

var transform = {'tag':'li','html':'${name} (${age})'};

Which assume I know what the json will have "name" and "age", is there a way to wildcard this and just take pairs in the same form but of any name?

Actually the library is fairly simple and the complete source code can be found here on github so feel free to pick apart if you like. As for documentation check out the website under examples to get started.

First Question "arbitrary json, and turn it into pretty html much like the "json visualizer" The simple answer is yes, you can visualize unstructured json using json2html. Although the visualizer is not part of the library it was however created using json2html. Have a look at the source code it's all nicely commented and it should give you a good idea on how we created it.

Second Question "is there a way to wildcard " Short answer is yes, simply use an inline function

 {'tag':'li','html':function() {
    return(this.myWildcardVariable);
 }}

However, since I'm a little confused as to what you're trying to achieve I would say start with the basics (examples) and you'll probably get a better grasp of what the library can do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM