1.1.2 • Published 1 year ago

json-custom-view v1.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Functions


generate(data, root, settings) - convert data according with converting settings and render it to root.

NameTypeDefaultDescription
dataString or Object''a string which is json or an object
rootDOM Elementundefineda DOM-node where the data will be rendered
settingsObject{}an object of settings

transform(data, settings) - convert data according with converting settings. Returns converted Object.

NameTypeDefaultDescription
dataObject''an object
settingsObject{}an object of settings

Fields of settings object


NameTypeDefaultDescription
rootString or Array''root of json which should be presented. Could be string or array. If it is "" the whole json will be presented. If it is a string will be returned data[root]. Array is a path to concrete value. E.g. if to use ['key1', 'key2', ... 'keyn'] you will get data[key1][key2]...[keyn]
isFormatKeysBooleanfalseif it is true all keys in CamesCase, snake_case, and kebab-case will be formatted to separate words
nullAppearenceStringundefinedstring by which will be replaced null values
boolAppearenceArray of two Stringsundefinedarray of strings by which will be replaced true and false values
hidePropertiesByValueArray of Stringsundefinedarray of values by which will be hided parameters of your json
hidePropertiesByKeyArray of Stringsundefinedarray of keys by which will be hided parameters of your json
hideEmptyBooleantruehide fields with an empty object and empty arrays as a value. Fields could also become empty after hiding inner fields
isMergeSingleFieldsBooleanfalseif there is only one field in an Object or only one element is in an Array it merges to parents field
keysForArraysObjectundefinedan abject where keys are names of arrays and values are properties which will be shown as keys for corresponding arrays
arraysAsTableArray of Strings[]array of keys of parameters which contain an array and which will be presented as a table
showNotificationsBooleantrueif it's true all errors and warnings will be visible
capitalizeKeysBooleanundefinedif it's true all keys will start from capital letter

Usage


import { generate } from 'json-custom-view';

const root = document.querySelector('#main');

generate(JSONdata, root, settings);
1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago