Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsoneditor

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsoneditor

A web-based tool to view, edit, format, and validate JSON

  • 10.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
118K
decreased by-32.06%
Maintainers
1
Weekly downloads
 
Created

What is jsoneditor?

The jsoneditor npm package is a web-based tool to view, edit, format, and validate JSON data. It provides a variety of features to manipulate JSON data in a user-friendly way, including a tree view, code view, and text view.

What are jsoneditor's main functionalities?

Tree View

The tree view allows users to view and edit JSON data in a structured, hierarchical format. This is useful for navigating complex JSON objects.

const JSONEditor = require('jsoneditor');
const container = document.getElementById('jsoneditor');
const options = { mode: 'tree' };
const editor = new JSONEditor(container, options);
const json = { 'array': [1, 2, 3], 'boolean': true, 'null': null, 'number': 123, 'object': { 'a': 'b', 'c': 'd' }, 'string': 'Hello World' };
editor.set(json);

Code View

The code view allows users to view and edit JSON data as raw text. This is useful for users who prefer to work directly with JSON code.

const JSONEditor = require('jsoneditor');
const container = document.getElementById('jsoneditor');
const options = { mode: 'code' };
const editor = new JSONEditor(container, options);
const json = { 'array': [1, 2, 3], 'boolean': true, 'null': null, 'number': 123, 'object': { 'a': 'b', 'c': 'd' }, 'string': 'Hello World' };
editor.set(json);

Text View

The text view allows users to view and edit JSON data as plain text. This is useful for quick edits and for users who are comfortable with text-based interfaces.

const JSONEditor = require('jsoneditor');
const container = document.getElementById('jsoneditor');
const options = { mode: 'text' };
const editor = new JSONEditor(container, options);
const json = { 'array': [1, 2, 3], 'boolean': true, 'null': null, 'number': 123, 'object': { 'a': 'b', 'c': 'd' }, 'string': 'Hello World' };
editor.set(json);

Validation

The validation feature allows users to define custom validation rules for their JSON data. This is useful for ensuring that JSON data meets specific requirements before it is used.

const JSONEditor = require('jsoneditor');
const container = document.getElementById('jsoneditor');
const options = { mode: 'code', onValidate: (json) => { const errors = []; if (!json.hasOwnProperty('requiredField')) { errors.push({ path: ['requiredField'], message: 'Field is required' }); } return errors; } };
const editor = new JSONEditor(container, options);
const json = { 'array': [1, 2, 3], 'boolean': true, 'null': null, 'number': 123, 'object': { 'a': 'b', 'c': 'd' }, 'string': 'Hello World' };
editor.set(json);

Other packages similar to jsoneditor

FAQs

Package last updated on 13 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc