πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

vue-json-pretty

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-json-pretty

A JSON tree view component that is easy to use and also supports data selection.

1.7.0-rc.0
Source
npm
Version published
Weekly downloads
163K
-3.7%
Maintainers
1
Weekly downloads
Β 
Created
Source

vue-json-pretty

Build Status npm package GitHub license

A vue 2.x component for rendering JSON data as a tree structure.

  • As a JSON Formatter
  • Get item data from JSON

Install

npm install vue-json-pretty --save

Usage

The CSS file is included separately and needs to be imported manually. You can either import CSS globally in your app (if supported by your framework) or directly from the component.

<template>
  <div>
    ...
    <vue-json-pretty
      :path="'res'"
      :data="{ key: 'value' }"
      @click="handleClick">
    </vue-json-pretty>
  </div>
</template>

<script>
import VueJsonPretty from 'vue-json-pretty'
import 'vue-json-pretty/styles.css';

export default {
  components: {
    VueJsonPretty
  }
}
</script>

Nuxt.js

  • In plugins/vue-json-pretty.js
import Vue from 'vue'
import VueJsonPretty from 'vue-json-pretty'

Vue.component("vue-json-pretty", VueJsonPretty);
  • In nuxt.config.js
css: [
  'vue-json-pretty/styles.css'
],
plugins: [
  '@/plugins/vue-json-pretty'
],

Props

  • If you are using only the normal features (JSON pretty), just focus on the base properties.
  • If you are using higher features (Get data), you can use base and higher attributes.
AttributeLevelDescriptionTypeDefault
datanormaljson dataJSON object-
deepnormaldata depth, data larger than this depth will not be expandednumberInfinity
showLengthnormalwhether to show the length when closedbooleanfalse
showLinenormalwhether to show the linebooleantrue
showDoubleQuotesnormalwhether to show doublequotes on keybooleantrue
highlightMouseoverNodenormalhighlight current node when mouseoverbooleanfalse
v-modelhigherdefines value when the tree can be selectedstring, array-, []
pathhigherroot data pathstringroot
pathCheckedhigherdefines the selected data patharray[]
pathSelectablehigherdefines whether a data path supports selectionFunction(itemPath, itemData)-
selectableTypehigherdefines the selected type, this feature is not supported by defaultenum: -, multiple, single-
showSelectControllerhigherwhether to show the select controller at leftbooleanfalse
selectOnClickNodehigherwhether to change selected value when click nodebooleantrue
highlightSelectedNodehigherhighlight current node when selectedbooleantrue
collapsedOnClickBracketshighercollapsed controlbooleantrue
customValueFormatterhighera function that can return different html or strings to display for values in the data.Function(data, key, parent, defaultFormatted)-

Events

Event NameDescriptionCallback Parameters
clicktriggered when a data item is clicked(path, data)
changetriggered when the selected value changed (only the selectableType not null)(newVal, oldVal)

Major Contributors

Keywords

vue

FAQs

Package last updated on 29 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts