Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
vscode-json-languageservice
Advanced tools
The vscode-json-languageservice npm package provides a set of services for working with JSON documents in a way that is compatible with the Visual Studio Code editor. It offers features such as validation, completion, hover information, and more, making it easier to build tools and extensions that work with JSON data.
Validation
This feature allows you to validate JSON documents. The code sample demonstrates how to use the language service to validate a JSON document and print out any diagnostics (errors or warnings) found.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doValidation(document, jsonDocument).then(diagnostics => {
console.log(diagnostics);
});
Completion
This feature provides auto-completion suggestions for JSON documents. The code sample shows how to get completion suggestions at a specific position in a JSON document.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doComplete(document, { line: 0, character: 1 }, jsonDocument).then(completionList => {
console.log(completionList);
});
Hover Information
This feature provides hover information for JSON documents. The code sample demonstrates how to get hover information at a specific position in a JSON document.
const { getLanguageService } = require('vscode-json-languageservice');
const languageService = getLanguageService({});
const document = { uri: 'file://test.json', languageId: 'json', version: 1, getText: () => '{ "key": "value" }' };
const jsonDocument = languageService.parseJSONDocument(document);
languageService.doHover(document, { line: 0, character: 1 }, jsonDocument).then(hover => {
console.log(hover);
});
jsonlint is a JSON parser and validator with a CLI. It is primarily used for validating JSON data and providing error messages. Unlike vscode-json-languageservice, it does not offer features like completion or hover information.
ajv is a JSON schema validator that supports JSON Schema draft-07 and other standards. It is highly performant and can be used for validating JSON data against schemas. While it focuses on validation, it does not provide language service features like completion or hover information.
json-schema-to-typescript converts JSON schemas to TypeScript interfaces. It is useful for generating TypeScript types from JSON schemas but does not offer the comprehensive language services provided by vscode-json-languageservice.
JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
The vscode-json-languageservice contains the language smarts behind the JSON editing experience of Visual Studio Code and the Monaco editor.
For the complete API see jsonLanguageService.ts and jsonLanguageTypes.ts
npm install --save vscode-json-languageservice
See sample.ts for an example on how to use the JSON language service.
To run the sample use yarn sample
git clone https://github.com/microsoft/vscode-json-languageservice
cd vscode-json-languageservice
yarn
Use yarn test
to compile and run tests
jsonCompletion.ts
yarn link vscode-json-languageservice
in vscode/extensions/json-language-features/server
to run VSCode with the latest changes from vscode-json-languageservice
vscode/scripts/code.sh|bat
) and open a .json
filevscode-json-languageservice
sources, run command Debug: Attach to Node process
and pick the code-oss
process with the json-language-features
path
jsonCompletion.ts
.json
fileFAQs
Language service for JSON
The npm package vscode-json-languageservice receives a total of 1,141,129 weekly downloads. As such, vscode-json-languageservice popularity was classified as popular.
We found that vscode-json-languageservice demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.