Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-json-languageservice

Package Overview
Dependencies
Maintainers
7
Versions
161
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-json-languageservice

Language service for JSON

  • 5.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4M
decreased by-2.49%
Maintainers
7
Weekly downloads
 
Created

What is vscode-json-languageservice?

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.

What are vscode-json-languageservice's main functionalities?

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);
});

Other packages similar to vscode-json-languageservice

FAQs

Package last updated on 02 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc