Skip to main content

parse_deno_json

Function parse_deno_json 

Source
pub fn parse_deno_json(
    content: &str,
    uri: &Uri,
) -> Result<DenoParseResult, DepsError>
Expand description

Parses a deno.json/deno.jsonc file and extracts all imports entries with positions.

§Errors

Returns an error if the content is not valid JSON/JSONC (malformed syntax, unclosed block comment, stray brace) — the file is then not recognized as a Deno manifest and degrades gracefully (spec §6), matching every other ecosystem’s parse-failure behavior.

§Examples

use deps_deno::parser::parse_deno_json;
use tower_lsp_server::ls_types::Uri;

let json = r#"{
  "imports": {
    "@std/fs": "jsr:@std/fs@^1.0"
  }
}"#;
let uri = Uri::from_file_path("/project/deno.json").unwrap();

let result = parse_deno_json(json, &uri).unwrap();
assert_eq!(result.dependencies.len(), 1);
assert_eq!(result.dependencies[0].name, "jsr:@std/fs");