@crft/jsonata-code-completion

0.0.2 • Public • Published

jsonata-code-completion

jsonata code completion built to be used in the monaco editor.

This is a code completer based on json schemas both for source and target data. Jsonata allows to build a json from another json input. Added with schemas for both input and output, this will add code completion. Note that for vscode, more work has to be done since vscode uses a language server.

usage

The schemas can either be addes as jsonata comments and supports http/s protocol only since fetch does not allow local file system access.

        /*sourceSchema=http://localhost:1234/schemas/testSchema.json*/
        /*targetSchema=http://localhost:1234/schemas/testSchema.json*/

Here url starting with sourceSchema and targetSchema will be extracted and loaded with fetch.

Also schemas can be loaded programmatically:

    let source = `
        {
            "obj": obj.name.{
                "aaa":{
                    "obj1":{`
        var exp = jsonata(source,{recover: true});
        var options = {
            //source: source,
            schemas: {
                sourceSchema: require("../tests/schemas/testSchema.json"),
                targetSchema: require("../tests/schemas/testSchema.json"),

            }
        }
        var proposals = await getProposals(exp.ast(), options);

Here the source and target schema is set from code.

installation

npm install

Quick start

node version: in examples/simpleExample.js

browser:

npm run browserify
node tests/server.js

http://localhost:1234/examples/index.html

Readme

Keywords

Package Sidebar

Install

npm i @crft/jsonata-code-completion

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

29.4 kB

Total Files

15

Last publish

Collaborators

  • sw-fp
  • re_fp
  • jgenere-fp
  • jtongus6
  • lmontanaro
  • jj_fp
  • wambosa
  • myspivey
  • aa-fp
  • taysmith92
  • hannuraina
  • jweinstein92
  • amcdnl
  • dsem
  • benturner-fp