Skip to content

python-jsonschema/jsonschema-lexer

Folders and files

NameName
Last commit message
Last commit date
Jan 16, 2025
Oct 21, 2024
Feb 27, 2024
Apr 7, 2025
Feb 27, 2024
Feb 29, 2024
Jan 16, 2025
Jan 16, 2025
Feb 27, 2024
Feb 29, 2024
Jan 16, 2025
Jan 16, 2025

Repository files navigation

jsonschema-lexer

PyPI version Supported Python versions Build status

Introduction

jsonschema-lexer provides a lexer for syntax highlighting JSON Schema documents via Pygments.

Usage

Once installed, you can use it in your Python code to highlight JSON Schema documents.

Here's a simple example:

from jsonschema_lexer import JSONSchemaLexer

from rich.console import Console
from rich.syntax import Syntax

console = Console()

code = """
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": "object",
  "properties": {
    "productId": {
      "description": "The unique identifier for a product",
      "type": "integer"
    },
    "productName": {
      "description": "Name of the product",
      "type": "string"
    }
  }
}
"""

syntax = Syntax(code, lexer=JSONSchemaLexer(), background_color="default", word_wrap=True)
console.print(syntax)