# @theia/json

> Theia - JSON Extension

Latest version **1.3.0** (published 2020-06-25) · EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @theia/json
pnpm add @theia/json
yarn add @theia/json
bun add @theia/json
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2020-06-25 |
| First published | 2018-05-14 |
| Weekly downloads | 0 |
| License | EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 73.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21759 |
| Maintainers | theia |
| Keywords | theia-extension |

## Links

- npm: https://www.npmjs.com/package/@theia/json
- Repository: https://github.com/eclipse-theia/theia
- Issues: https://github.com/eclipse-theia/theia/issues
- npm.io page: https://npm.io/package/@theia/json

## Dependencies (5)

- [@theia/core](https://npm.io/package/@theia/core.md) ^1.3.0
- [@theia/monaco](https://npm.io/package/@theia/monaco.md) ^1.3.0
- [@theia/languages](https://npm.io/package/@theia/languages.md) ^1.3.0
- [@theia/application-package](https://npm.io/package/@theia/application-package.md) ^1.3.0
- [vscode-json-languageserver](https://npm.io/package/vscode-json-languageserver.md) ^1.2.1

## Recent versions

- 1.3.0 (latest) — 2020-06-25
- 1.4.0-next.e23180f9 (next) — 2020-07-02
- 0.4.0-testnext.d1b1bc8c (testnext) — 2019-01-22
- 1.4.0-next.64244a58 — 2020-07-01
- 1.4.0-next.dfcfccc1 — 2020-07-01
- 1.4.0-next.250841db — 2020-06-30
- 1.4.0-next.68a3453e — 2020-06-29
- 1.4.0-next.e4d87c7c — 2020-06-29
- 1.4.0-next.a62011a5 — 2020-06-29
- 1.4.0-next.3f42537a — 2020-06-26
- 1.4.0-next.bb854525 — 2020-06-26
- 1.4.0-next.27af791e — 2020-06-25
- 1.3.0-next.9657f69c — 2020-06-25
- 1.3.0-next.f5c08277 — 2020-06-25
- 1.3.0-next.4c2af31a — 2020-06-24
- … 1451 more at https://npm.io/package/@theia/json/versions

## README

<div align='center'>

<br />

<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />

<h2>THEIA - JSON EXTENSION</h2>

<hr />

</div>

## Description

The `@theia/json` extension contributes the following features:
- Syntax Coloring for JSON including support for jsonc (i.e. comments)
- [Code completion](https://microsoft.github.io/language-server-protocol/specification#textDocument_completion) for JSON properties and values based on the document's [JSON schema](http://json-schema.org/) or based on existing properties and values used at other places in the document. JSON schemas are configured through the server configuration options.
- [Hover](https://microsoft.github.io/language-server-protocol/specification#textDocument_hover) for values based on descriptions in the document's [JSON schema](http://json-schema.org/).
- [Document Symbols](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol) for quick navigation to properties in the document.
- [Document Colors](https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor) for showing color decorators on values representing colors and [Color Presentation](https://microsoft.github.io/language-server-protocol/specification#textDocument_colorPresentation) for color presentation information to support color pickers. The location of colors is defined by the document's [JSON schema](http://json-schema.org/). All values marked with `"format": "color-hex"` (VSCode specific, non-standard JSON Schema extension) are considered color values. The supported color formats are `#rgb[a]` and `#rrggbb[aa]`.
- [Code Formatting](https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting) supporting ranges and formatting the whole document.
- [Diagnostics (Validation)](https://microsoft.github.io/language-server-protocol/specification#textDocument_publishDiagnostics) are pushed for all open documents
   - syntax errors
   - structural validation based on the document's [JSON schema](http://json-schema.org/).

In order to load JSON schemas, the JSON server uses NodeJS `http` and `fs` modules. For all other features, the JSON server only relies on the documents and settings provided by the client through the LSP.

### Settings

Clients may send a `workspace/didChangeConfiguration` notification to notify the server of settings changes.
The server supports the following settings:

- http
   - `proxy`: The URL of the proxy server to use when fetching schema. When undefined or empty, no proxy is used.
   - `proxyStrictSSL`: Whether the proxy server certificate should be verified against the list of supplied CAs.

- json
  - `format`
    - `enable`: Whether the server should register the formatting support. This option is only applicable if the client supports *dynamicRegistration* for *rangeFormatting*
    - `schema`: Configures association of file names to schema URL or schemas and/or associations of schema URL to schema content.
	  - `fileMatch`: an array or file names or paths (separated by `/`). `*` can be used as a wildcard.
	  - `url`: The URL of the schema, optional when also a schema is provided.
	  - `schema`: The schema content.

```json
	{
        "http": {
            "proxy": "",
            "proxyStrictSSL": true
        },
        "json": {
            "format": {
                "enable": true
            },
            "schemas": [
                {
                    "fileMatch": [
                        "foo.json",
                        "*.superfoo.json"
                    ],
                    "url": "http://json.schemastore.org/foo",
                    "schema": {
                    	"type": "array"
                    }
                }
            ]
        }
    }
```

### Schema configuration and custom schema content delivery

[JSON schemas](http://json-schema.org/) are essential for code assist, hovers, color decorators to work and are required for structural validation.

To find the schema for a given JSON document, the server uses the following mechanisms:
- JSON documents can define the schema URL using a `$schema` property
- The settings define a schema association based on the documents URL. Settings can either associate a schema URL to a file or path pattern, and they can directly provide a schema.
- Additionally, schema associations can also be provided by a custom 'schemaAssociations' configuration call.

Schemas are identified by URLs. To load the content of a schema, the JSON language server tries to load from that URL or path. The following URL schemas are supported:
- `http`, `https`: Loaded using NodeJS's HTTP support. Proxies can be configured through the settings.
- `file`: Loaded using NodeJS's `fs` support.
- `vscode`: Loaded by an LSP call to the client.

#### Schema associations notification

In addition to the settings, schemas associations can also be provided through a notification from the client to the server. This notification is a JSON language server specific, non-standardized, extension to the LSP.

Notification:
- method: 'json/schemaAssociations'
- params: `ISchemaAssociations` defined as follows

```ts
interface ISchemaAssociations {
	[pattern: string]: string[];
}
```
  - keys: a file names or file path (separated by `/`). `*` can be used as a wildcard.
  - values: An array of schema URLs

#### Schema content request

The schema content for schema URLs that start with `vscode://` will be requested from the client through an LSP request. This request is a JSON language server specific, non-standardized, extension to the LSP.

Request:
- method: 'vscode/content'
- params: `string` - The schema URL to request. The server will only ask for URLs that start with `vscode://`
- response: `string` - The content of the schema with the given URL

#### Schema content change notification

When the client is aware that a schema content has changed, it will notify the server through a notification. This notification is a JSON language server specific, non-standardized, extension to the LSP.
The server will, as a response, clear the schema content from the cache and reload the schema content when required again.

Notification:
- method: 'json/schemaContent'
- params: `string` the URL of the schema that has changed.

## Additional Information

- [API documentation for `@theia/json`](https://eclipse-theia.github.io/theia/docs/next/modules/json.html)
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
- [Theia - Website](https://theia-ide.org/)

## License

- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)

## Trademark
"Theia" is a trademark of the Eclipse Foundation
https://www.eclipse.org/theia

---
_Source: https://npm.io/package/@theia/json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
