![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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.
doValidation analyses an input string and returns syntax and lint errors.
doComplete provides completion proposals for a given location. doResolve resolves a completion proposal
doResolve resolves a completion proposals.
doHover provides a hover text for a given location.
findDocumentSymbols provides all symbols in the given document
findDocumentColors provides all color symbols in the given document, getColorPresentations returns available color formats for a color symbol.
format formats the code at the given range.
getFoldingRanges gets folding ranges for the given document
getSelectionRanges gets selection ranges for a given location.
getMatchingSchemas matches a document against its schema and returns all AST nodes along with the matching sub schemas
use parseJSONDocument create a JSON document from source code, or newJSONDocument to create the document from an AST.
npm install --save vscode-json-languageservice
FAQs
Language service for JSON
The npm package vscode-json-languageservice receives a total of 824,881 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.