Skip to content

parse json as such#379

Merged
anatoly-scherbakov merged 4 commits intomasterfrom
parse-json-as-such
Feb 4, 2026
Merged

parse json as such#379
anatoly-scherbakov merged 4 commits intomasterfrom
parse-json-as-such

Conversation

@anatoly-scherbakov
Copy link
Contributor

@anatoly-scherbakov anatoly-scherbakov commented Feb 4, 2026

  • JSONDocumentParser
  • Register JSON parser
  • Bump

Note

Medium Risk
Changes how JSON and JSON-LD documents are parsed and which parser is selected for common content types, which could affect existing consumers expecting YAML-style behavior or error semantics. The change is localized but impacts document loading paths.

Overview
JSON/JSON-LD documents are now parsed as JSON. This introduces JSONDocumentParser (UTF-8 decode + json.loads, rejects scalar documents) and registers it for application/json and application/ld+json in document_loaders/content_types.py (previously routed to YAMLDocumentParser).

Bumps package version to 1.1.17 and adds a minimal flake8 config (max-imports = 15) in setup.cfg.

Written by Cursor Bugbot for commit 928e5cb. This will update automatically on new commits. Configure here.

@anatoly-scherbakov anatoly-scherbakov self-assigned this Feb 4, 2026
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Test Diff Report

Nothing had changed in tests.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Coverage

Coverage Report
FileStmtsMissCoverMissing
yaml_ld
   cli.py1061060%1–390
   compact.py23578%59–69
   errors.py771383%38, 86–98, 103–104, 186
   expand.py422443%48–61, 72–82, 96–109
   flatten.py18572%51–61
   frame.py26485%59–63
   from_rdf.py20480%32–36
   load_document.py16756%28–42
   models.py24196%64
   options.py20290%33–36
   string_as_url_or_path.py6350%8–11
yaml_ld/document_loaders
   base.py8188%25
   choice_by_scheme.py30487%28, 33, 52–53
   content_types.py42881%38, 51–61, 139–140
   http.py1154858%52–61, 70–114, 122–132, 142–149, 186, 193–194, 198, 224–229, 244, 253–261, 264, 274, 297–308
   local_file.py21481%24, 31, 40–41
   mock.py880%1–19
yaml_ld/document_parsers
   base.py8188%19
   html_parser.py815828%45–79, 89–122, 134–158, 167–196
   json_parser.py20575%19, 36–37, 41–42
   markdown_parser.py17947%24–36
   rdf_xml_parser.py9278%23–24
   turtle_parser.py9278%23–24
   yaml_parser.py411759%28, 51–52, 67–80, 86–89
TOTAL86534161% 

Tests Skipped Failures Errors Time
1 0 💤 0 ❌ 1 🔥 2.408s ⏱️

@anatoly-scherbakov anatoly-scherbakov merged commit 449c815 into master Feb 4, 2026
3 checks passed
@anatoly-scherbakov anatoly-scherbakov deleted the parse-json-as-such branch February 4, 2026 17:31
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

if not isinstance(document, (dict, list)):
raise DocumentIsScalar(document)

return document
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated ensure_not_scalar function already exists

Medium Severity

The ensure_not_scalar function is duplicated. An identical implementation already exists in yaml_ld/document_parsers/yaml_parser.py (lines 25-30). The markdown_parser.py already imports and uses the existing function from yaml_parser.py, which is the correct pattern to follow.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant