Skip to content

Files

Latest commit

 

History

History

lang-jsonc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@shopify/lang-jsonc

CodeMirror 6 Language Support for VS Code's flavour of JSON with Comments. Trailing commas included.

Usage

import { basicSetup } from 'codemirror';
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { jsonc } from '@shopify/lang-jsonc';

new EditorView({
  parent: document.getElementById('json-editor'),
  state: EditorState.create({
    doc: `
      {
        // this is a comment
        "product": "Apple",

        /* block comment, with trailing comma */
        "price": "1.00$",
      }
    `
    extensions: [
      basicSetup,
      jsonc(),
    ],
  }),
});

Credits

This project includes code from the following repositories. Thank you for your work!

  1. @yettoapp/jsonc
  2. @lezer/json
  3. @codemirror/lang-json

See ThirdPartyNotices.txt for their licenses.

License

MIT.