jsoneditor README

The project's README from github.com/josdejong/jsoneditor. As one markdown file: README.md.

JSON Editor

Version Downloads Maintenance License FOSSA Status

JSON Editor is a web-based tool to view, edit, format, and validate JSON. It has various modes such as a tree editor, a code editor, and a plain text editor. The editor can be used as a component in your own web application. It can be loaded as CommonJS module, AMD module, or as a regular javascript file.

The library was originally developed as core component of the popular web application https://jsoneditoronline.org and has been open sourced since then.

Supported browsers: Chrome, Firefox, Safari, Edge.

json editor   code editor

Continuous integration tests are run on GitHub Actions, and LambdaTest is used to test on all major browsers.

LambdaTest

Thanks, GitHub Actions and LambdaTest for the generous support for this open source project!

Successor: svelte-jsoneditor

This library jsoneditor has a successor: svelte-jsoneditor. The new editor is not a one-to-one replacement, so there may be reasons to stick with jsoneditor. The main differences between the two are described here.

Features

JSONEditor has various modes, with the following features.

Tree mode

Code mode

Text mode

Preview mode

Documentation

Install

with npm (recommended):

npm install jsoneditor

Alternatively, you can use another JavaScript package manager like https://yarnpkg.com/, or a CDN such as https://cdnjs.com/ or https://www.jsdelivr.com/.

Use

Note that in the following example, you'll have to change the urls jsoneditor/dist/jsoneditor.min.js and jsoneditor/dist/jsoneditor.min.css to match the place where you've downloaded the library, or fill in the URL of the CDN you're using.

<!DOCTYPE HTML>
<html lang="en">
<head>
    <!-- when using the mode "code", it's important to specify charset utf-8 -->
    <meta charset="utf-8">

    <link href="jsoneditor/dist/jsoneditor.min.css" rel="stylesheet" type="text/css">
    <script src="jsoneditor/dist/jsoneditor.min.js"></script>
</head>
<body>
    <div id="jsoneditor" style="width: 400px; height: 400px;"></div>

    <script>
        // create the editor
        const container = document.getElementById("jsoneditor")
        const options = {}
        const editor = new JSONEditor(container, options)

        // set json
        const initialJson = {
            "Array": [1, 2, 3],
            "Boolean": true,
            "Null": null,
            "Number": 123,
            "Object": {"a": "b", "c": "d"},
            "String": "Hello World"
        }
        editor.set(initialJson)

        // get json
        const updatedJson = editor.get()
    </script>
</body>
</html>

Build

The code of the JSON Editor is located in the folder ./src. To build jsoneditor:

Test

Run unit tests:

npm test

Run code linting (JavaScript Standard Style):

npm run lint

License

jsoneditor is released as open source under the permissive the Apache 2.0 license.

If you are using jsoneditor commercially, there is a social (but no legal) expectation that you help fund its maintenance. Start here.

jsoneditor (josdejong/jsoneditor)

Searching Database…

这是干什么的?一个在浏览器里直接查看、编辑、格式化和校验 JSON 的网页工具,不用再去硬啃原始文本。
它是独立应用,还是能嵌进我自己网页应用里的库?它是给你自己的网页应用用的组件,不是托管好的应用:可以按 CommonJS 模块、AMD 模块或普通 JavaScript 文件的方式加载。
怎么把它加到网页上?把 dist 文件夹里构建好的 jsoneditor.min.js 和 jsoneditor.min.css 引入你的页面,或者把地址指向 CDN 上的副本。
我还需要自己搭配其他库吗?不用自己配:Ace(代码编辑器)、ajv(schema 校验)和 jsonrepair 已经作为 npm 依赖打包进去了,所以只要这两个构建出来的文件就够用。
随便什么浏览器都能用吗?它面向浏览器环境:Chrome、Firefox、Safari 和 Edge 是官方支持的浏览器。
商业项目里能免费用吗?免费开源,采用宽松的 Apache 2.0 许可证;对商业用户来说,资助维护是一种道义上的期望,而不是法律义务。
它提供哪几种编辑模式?三种:树状编辑器,可以点击展开结构化数据;基于 Ace 的代码编辑器,适合按文本编辑;还有一个纯文本编辑器。
除了编辑,它对我的 JSON 还能做什么?它能通过内置的 ajv 按 JSON Schema 做校验,能用 jsonrepair 修复出错的 JSON,还通过 jmespath 支持 JMESPath 查询。
这个项目是怎么来的?它最初是一个热门网页应用的核心组件,后来从那里开源出来;GitHub 仓库可以追溯到 2012 年。
Creator
josdejong
Size
62.3 MB
Stars
12.3K
Updated
CommitJul 30
Age
14y
Commits · 90 Days