yourtion / vue-json-ui-editor

Edit JSON in UI form with JSON Schema and Vue.js
http://jsonui.js.org/
MIT License
507 stars 97 forks source link
json json-editor json-schema json-ui-schema schema vue vue-editor vue-json-editor vue-json-schema

NPM version build status Test coverage David deps npm download npm license

json-editor

Greenkeeper badge DeepScan grade

Edit JSON in UI form with JSON Schema and Vue.js <json-editor> component.

ScreenShot

Install

npm install vue-json-ui-editor --save

Use

<template>
<json-editor ref="JsonEditor" :schema="schema" v-model="model">
    <button @click="submit">submit</button>
    <button @click="reset">Reset</button>
</json-editor>
</template>

<script>
const SCHEMA = {
  type: 'object',
  title: 'vue-json-editor demo',
  properties: {
    name: {
      type: 'string',
    },
    email: {
      type: 'string',
    },
  },
};
// import vue-json-ui-editor
import JsonEditor from 'vue-json-ui-editor';
export default {
  components: { JsonEditor },
  data: () => ({
    // init json schma file ( require('@/schema/newsletter') )
    schema: SCHEMA,
    // data
    model: {
      name: 'Yourtion',
    },
  }),

  methods: {
    submit(_e) {
      alert(JSON.stringify(this.model));
    },
    reset() {
      this.$refs.JsonEditor.reset();
    },
  },
};
</script>

More info on: Example-Subscription Schema: newsletter.json

props

data

events

methods