在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:caldwell/renderjson开源软件地址:https://github.com/caldwell/renderjson开源编程语言:JavaScript 56.6%开源软件介绍:RenderjsonRender JSON into collapsible, themeable HTML. This library aims to be very simple with few options and no external dependencies. It's aimed at debugging but you can use it wherever it is useful. The code renders the JSON lazily, only building the HTML when the user reveals the JSON by clicking the disclosure icons. This makes it extremely fast to do the initial render of huge JSON objects, since the only thing that renders initially is a single disclosure icon. Live ExampleA live example can be found here. Example<div id="test"></div>
<script type="text/javascript" src="renderjson.js"></script>
<script>
document.getElementById("test").appendChild(
renderjson({ hello: [1,2,3,4], there: { a:1, b:2, c:["hello", null] } })
);
</script> UsageThe module exports one entry point, the OptionsThere are a couple functions to call to customize the output: renderjson.set_icons('+', '-'); Call renderjson.set_show_to_level(level); Call renderjson.set_max_string_length(length); Strings will be truncated and made expandable if they are longer than
renderjson.set_sort_objects(sort_bool); Sort objects by key (default: false) renderjson.set_replacer(replacer_function)
renderjson.set_property_list(property_list) These are the equivalent of the JSON.stringify() renderjson.set_collapse_msg(collapse_function); Accepts a function (len:number):string => {} where len is the length of the object collapsed. Function should return the message displayed when a object is collapsed. The default message is "X items". These functions are chainable so you may do: renderjson.set_icons('+', '-')
.set_show_to_level(2)
({ hello: [1,2,3,4], there: { a:1, b:2, c:["hello", null] } }) ThemingThe HTML output uses a number of classes so that you can theme it the way you'd like:
Copyright and LicenseLicense: ISC Copyright © 2013-2017 David Caldwell <[email protected]> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论