vue3-json-editor is a Vue.js 3 component that provides an interactive JSON editor. It's a direct fork of the `vue-json-editor` library, specifically tailored for Vue 3 applications, distinguishing it from older Vue 2 compatible versions. The package, currently at version 1.1.5, allows developers to display and edit JSON objects within their Vue components, supporting various modes like 'tree', 'view', and 'form'. It offers features such as displaying save buttons, expanding the editor on start, and handling different languages. The component provides `v-model` binding for the JSON data and emits events for changes (`json-change`), saves (`json-save`), and errors (`has-error`). It supports modern module systems including ESM and CommonJS, making it compatible with various build setups like Vite and webpack. While no explicit release cadence is stated, updates appear to be driven by maintenance and new feature integration from its upstream source.
npm install vue3-json-editorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `vue3-json-editor` into a Vue 3 component using the Composition API, binding a JSON object with `v-model` and handling change and error events.
Ensure your project is running Vue 3.x. For Vue 2 projects, seek a compatible JSON editor component or migrate your application to Vue 3.
Always initialize `v-model` with an appropriate JavaScript object (for `mode='tree'`) or a JSON string (for `mode='text'`). The `onJsonChange` event provides the updated value in the correct type.
Wrap your JSON data in `reactive` or `ref`. For example, `const state = reactive({ json: {} })` and then spread `...toRefs(state)` in the return object, or use `const json = ref({})`.Check for common module resolution issues (e.g., in `vite.config.js` for Vite projects, consider `@originjs/vite-plugin-commonjs` if using CommonJS dependencies). Ensure the component is correctly registered and mounted. Verify that the editor's internal dependencies are resolving correctly.
Ensure you have `import { Vue3JsonEditor } from 'vue3-json-editor'` in your script and added it to the `components` option: `components: { Vue3JsonEditor }`.Initialize your `v-model` data property with an empty object (e.g., `{}`) or a valid JSON object. For example, `const state = reactive({ json: {} })`.For Vite projects, if the issue persists, consider adding `@originjs/vite-plugin-commonjs` to your `vite.config.js` to improve CommonJS compatibility. Also, review recent changes in the library's changelog for breaking build-related changes.