{"name":"vanilla-jsoneditor","version":"3.2.0","license":"ISC","_id":"vanilla-jsoneditor@3.2.0","maintainers":[{"name":"josdejong","email":"wjosdejong@gmail.com"}],"homepage":"https://github.com/josdejong/svelte-jsoneditor","bugs":{"url":"https://github.com/josdejong/svelte-jsoneditor/issues"},"dist":{"shasum":"fb64f65d83d33fcfba5312f22430a09a217c4ff1","tarball":"http://registry-npm.ywwl.com/vanilla-jsoneditor/download/vanilla-jsoneditor-3.2.0.tgz","fileCount":13,"integrity":"sha512-v/iSK6SKBoqnM5jrWesInyQdNdI/QBy5V8COamQe97B5+BdDAkUhTFh+0hWsaAP2FCsLWIBKGhRHooqNxdGTfA==","signatures":[{"sig":"MEUCIHZ0lt+LkQw60hKhWzd84KbQfcLkpCskC52mSY1kK80hAiEA4q31eSdBTaxEImavfb/ujFC79VlsirJFMZfwZ0SCCvg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9528536,"size":2572784,"noattachment":false,"key":"/vanilla-jsoneditor/-/vanilla-jsoneditor-3.2.0.tgz"},"main":"./index.js","type":"module","types":"./index.d.ts","module":"./index.js","browser":"./standalone.js","exports":{".":"./index.js","./index.js":"./index.js","./README.md":"./README.md","./LICENSE.md":"./LICENSE.md","./index.d.ts":"./index.d.ts","./SECURITY.md":"./SECURITY.md","./CHANGELOG.md":"./CHANGELOG.md","./index.js.map":"./index.js.map","./standalone.js":"./standalone.js","./standalone.d.ts":"./standalone.d.ts","./standalone.js.map":"./standalone.js.map","./themes/jse-theme-dark.css":"./themes/jse-theme-dark.css","./themes/jse-theme-default.css":"./themes/jse-theme-default.css"},"gitHead":"89c043ae5e368a1a9b76fa7240fe6e652b1b25f8","scripts":{},"_npmUser":{"name":"josdejong","email":"wjosdejong@gmail.com"},"repository":{"url":"git+https://github.com/josdejong/svelte-jsoneditor.git","type":"git"},"_npmVersion":"11.1.0","description":"A web-based tool to view, edit, format, transform, and validate JSON","directories":{},"sideEffects":false,"_nodeVersion":"23.9.0","dependencies":{"ajv":"^8.17.1","svelte":"^5.0.0","jmespath":"^0.16.0","lodash-es":"^4.17.21","jsonrepair":"^3.0.0","memoize-one":"^6.0.0","jsonpath-plus":"^10.3.0","diff-sequences":"^29.6.3","vanilla-picker":"^2.12.3","json-source-map":"^0.6.1","@codemirror/lint":"^6.8.2","@codemirror/view":"^6.34.1","@lezer/highlight":"^1.2.1","@codemirror/state":"^6.4.1","@codemirror/search":"^6.5.6","@codemirror/commands":"^6.7.1","@codemirror/language":"^6.10.3","immutable-json-patch":"^6.0.1","natural-compare-lite":"^1.4.0","@codemirror/lang-json":"^6.0.1","@codemirror/autocomplete":"^6.18.1","@jsonquerylang/jsonquery":"^3.1.1 || ^4.0.0","codemirror-wrapped-line-indent":"^1.0.8","@fortawesome/free-solid-svg-icons":"^6.6.0","@fortawesome/free-regular-svg-icons":"^6.6.0","@replit/codemirror-indentation-markers":"^6.5.3"},"_hasShrinkwrap":false,"devDependencies":{},"peerDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/vanilla-jsoneditor_3.2.0_1743004122405_0.1836007661095389","host":"s3://npm-registry-packages-npm-production"},"readme":"# vanilla-jsoneditor\n\nA web-based tool to view, edit, format, transform, and validate JSON.\n\nTry it out: <https://jsoneditoronline.org>\n\nThis is the vanilla variant of `svelte-jsoneditor`, which can be used in vanilla JavaScript or frameworks like SolidJS, React, Vue, Angular.\n\n![JSONEditor tree mode screenshot](https://raw.githubusercontent.com/josdejong/svelte-jsoneditor/main/misc/jsoneditor_tree_mode_screenshot.png)\n![JSONEditor text mode screenshot](https://raw.githubusercontent.com/josdejong/svelte-jsoneditor/main/misc/jsoneditor_text_mode_screenshot.png)\n![JSONEditor table mode screenshot](https://raw.githubusercontent.com/josdejong/svelte-jsoneditor/main/misc/jsoneditor_table_mode_screenshot.png)\n\n## Features\n\n- View and edit JSON\n- Has a low level text editor and high level tree view and table view\n- Format (beautify) and compact JSON\n- Sort, query, filter, and transform JSON\n- Repair JSON\n- JSON schema validation and pluggable custom validation\n- Color highlighting, undo/redo, search and replace\n- Utilities like a color picker and timestamp tag\n- Handles large JSON documents up to 512 MB\n\n## Install\n\nInstall using npm:\n\n```\nnpm install vanilla-jsoneditor\n```\n\nRemark: for usage in a Svelte project, install and use `svelte-jsoneditor` instead of `vanilla-jsoneditor`.\n\n## Use\n\nIf you have a setup for your project with a bundler (like Vite, Rollup, or Webpack), it is best to use the default ES import:\n\n```ts\n// for use in a React, Vue, or Angular project\nimport { createJSONEditor } from 'vanilla-jsoneditor'\n```\n\nIf you want to use the library straight in the browser, use the provided standalone ES bundle:\n\n```ts\n// for use directly in the browser\nimport { createJSONEditor } from 'vanilla-jsoneditor/standalone.js'\n```\n\nThe standalone bundle contains all dependencies of `vanilla-jsoneditor`, for example `lodash-es` and `Ajv`. If you use some of these dependencies in your project too, it means that they will be bundled twice in your web application, leading to a needlessly large application size. In general, it is preferable to use the default `import { createJSONEditor } from 'vanilla-jsoneditor'` so dependencies can be reused.\n\n## Use (Browser example loading the ES module)\n\n```html\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <title>JSONEditor</title>\n  </head>\n  <body>\n    <div id=\"jsoneditor\"></div>\n\n    <script type=\"module\">\n      import { createJSONEditor } from 'vanilla-jsoneditor/standalone.js'\n\n      // Or use it through a CDN (not recommended for use in production):\n      // import { createJSONEditor } from 'https://unpkg.com/vanilla-jsoneditor/index.js'\n      // import { createJSONEditor } from 'https://cdn.jsdelivr.net/npm/vanilla-jsoneditor/index.js'\n\n      let content = {\n        text: undefined,\n        json: {\n          greeting: 'Hello World'\n        }\n      }\n\n      const editor = createJSONEditor({\n        target: document.getElementById('jsoneditor'),\n        props: {\n          content,\n          onChange: (updatedContent, previousContent, { contentErrors, patchResult }) => {\n            // content is an object { json: JSONData } | { text: string }\n            console.log('onChange', { updatedContent, previousContent, contentErrors, patchResult })\n            content = updatedContent\n          }\n        }\n      })\n\n      // use methods get, set, update, and onChange to get data in or out of the editor.\n      // Use updateProps to update properties.\n    </script>\n  </body>\n</html>\n```\n\n## Use (React example, including NextJS)\n\n### First, create a React component to wrap the vanilla-jsoneditor\n\nDepending on whether you are using JavaScript of TypeScript, create either a JSX or TSX file:\n\n### TypeScript\n\n```tsx\n//\n// JSONEditorReact.tsx\n//\nimport { useEffect, useRef } from 'react'\nimport { createJSONEditor, JSONEditorPropsOptional } from 'vanilla-jsoneditor'\n\nconst JSONEditorReact: React.FC<JSONEditorPropsOptional> = (props) => {\n  const refContainer = useRef<HTMLDivElement>(null)\n  const refEditor = useRef<JSONEditor | null>(null)\n\n  useEffect(() => {\n    // create editor\n    refEditor.current = createJSONEditor({\n      target: refContainer.current!,\n      props: {}\n    })\n\n    return () => {\n      // destroy editor\n      if (refEditor.current) {\n        refEditor.current.destroy()\n        refEditor.current = null\n      }\n    }\n  }, [])\n\n  useEffect(() => {\n    // update props\n    if (refEditor.current) {\n      refEditor.current.updateProps(props)\n    }\n  }, [props])\n\n  return <div ref={refContainer}></div>\n}\n\nexport default JSONEditorReact\n```\n\n### JavaScript\n\n```jsx\n//\n// JSONEditorReact.jsx\n//\nimport { useEffect, useRef } from 'react'\nimport { JSONEditor, JSONEditorPropsOptional } from 'vanilla-jsoneditor'\n\nconst JSONEditorReact = (props) => {\n  const refContainer = useRef(null)\n  const refEditor = useRef(null)\n\n  useEffect(() => {\n    // create editor\n    refEditor.current = createJSONEditor({\n      target: refContainer.current,\n      props: {}\n    })\n\n    return () => {\n      // destroy editor\n      if (refEditor.current) {\n        refEditor.current.destroy()\n        refEditor.current = null\n      }\n    }\n  }, [])\n\n  // update props\n  useEffect(() => {\n    if (refEditor.current) {\n      refEditor.current.updateProps(props)\n    }\n  }, [props])\n\n  return <div ref={refContainer}></div>\n}\n\nexport default JSONEditorReact\n```\n\n### Import and use the React component\n\nIf you are using NextJS, you will need to use a dynamic import to only render the component in the browser (disabling server-side rendering of the wrapper), as shown below in a NextJS TypeScript example.\n\nIf you are using React in an conventional non-NextJS browser app, you can import the component using a standard import statement like `import JSONEditorReact from '../JSONEditorReact'`\n\n```tsx\n//\n// demo.tsx for use with NextJS\n//\nimport dynamic from 'next/dynamic'\nimport { useCallback, useState } from 'react'\n\n//\n// In NextJS, when using TypeScript, type definitions\n// can be imported from 'vanilla-jsoneditor' using a\n// conventional import statement (prefixed with 'type',\n// as shown below), but only types can be imported this\n// way. When using NextJS, React components and helper\n// functions must be imported dynamically using { ssr: false }\n// as shown elsewhere in this example.\n//\nimport type { Content, OnChangeStatus } from 'vanilla-jsoneditor'\n\n//\n// In NextJS, the JSONEditor component must be wrapped in\n// a component that is dynamically in order to turn off\n// server-side rendering of the component. This is neccessary\n// because the vanilla-jsoneditor code attempts to use\n// browser-only JavaScript capabilities not available\n// during server-side rendering. Any helper functions\n// provided by vanilla-jsoneditor, such as toTextContent,\n// must also only be used in dynamically imported,\n// ssr: false components when using NextJS.\n//\nconst JSONEditorReact = dynamic(() => import('../JSONEditorReact'), { ssr: false })\nconst TextContent = dynamic(() => import('../TextContent'), { ssr: false })\n\nconst initialContent = {\n  hello: 'world',\n  count: 1,\n  foo: ['bar', 'car']\n}\n\nexport default function Demo() {\n  const [jsonContent, setJsonContent] = useState<Content>({ json: initialContent })\n  const handler = useCallback(\n    (content: Content, previousContent: Content, status: OnChangeStatus) => {\n      setJsonContent(content)\n    },\n    [jsonContent]\n  )\n\n  return (\n    <div>\n      <JSONEditorReact content={jsonContent} onChange={handler} />\n      <TextContent content={jsonContent} />\n    </div>\n  )\n}\n```\n\n```tsx\n//\n// TextContent.tsx\n//\n// (wrapper around toTextContent for use with NextJS)\n//\nimport { Content, toTextContent } from 'vanilla-jsoneditor'\n\ninterface IOwnProps {\n  content: Content\n}\nconst TextContent = (props: IOwnProps) => {\n  const { content } = props\n\n  return (\n    <p>\n      The contents of the editor, converted to a text string, are: {toTextContent(content).text}\n    </p>\n  )\n}\n\nexport default TextContent\n```\n","publish_time":1743004122686,"_cnpm_publish_time":1743004122686,"dist-tags":{"beta":"0.11.0-beta.3","latest":"3.13.0"}}