Quantcast
Viewing all articles
Browse latest Browse all 74

Is code completion for string values in JSON files possible?

I'm currently working with JSON files and exploring the possibility of implementing code completion specifically for string values within these files. To provide context, if I break it down, my JSON structure could look like the following:

{"$schema": "./schemas/example.schema.json","version": 1,"definition": "root/node1/subnode3/container2/parameter1","value": "true"}

The key definition is of type string and is the one I would be interested for the completion feature.

My IDE provides a keyboard shortcut for suggestions for the keys like "version" and "definition" but obviously by default not for the path string that would be possible for the definition key.

I want to inject the Path tree that I have available into the JSON schema to provide the possibility for the IDE to suggest valid paths e.g. for the definition value. Is that possible for standard JSON files?

I got the hint to set up a separate JSON acting like a kind of Database:

["root/node1/subnode1","root/node1/subnode2","root/node1/subnode3","root/node2/subnode1/container1","root/node2/subnode1/container2","root/node2/subnode2","root/node2/subnode3/container1","root/node2/subnode3/container2/parameter1","root/node2/subnode3/container2/parameter2"]

and then incorporate that into my original JSON file schema:

"definition": {"type": "string","description": "The definition path.","autocomplete": true,"autocompletePath": "./myDatabase.json"          }

but that did not work as intended.


Viewing all articles
Browse latest Browse all 74

Trending Articles