GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Recognize .jsonc files without implying JSON5 support by leoshone · Pull Request #255 · NPP-JSONViewer/JSON-Viewer

Conversation

@leoshone

@leoshone leoshone commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Following the review comment on #251 ("Let's remove JSON5 as it is not supported currently by the plugin") - this is a version that does not accept the JSON5 language at all. It only recognises the .jsonc extension, and a real .json5 file keeps behaving exactly as before this change.

Why anything at all

Notepad++ maps the .jsonc extension to the json5 language ("json5 jsonc" share one entry in the default langs.xml), so IsJsonFile() - the gate for draw-on-open, follow-tab and auto-format - returned false for every jsonc document, even though the parser itself handles jsonc content fine (ignoring comments and trailing commas is configurable and on by default).

The change

IsJsonFile() now accepts the json5 language only when the current file's extension is .jsonc:

if (languageType == LangType::L_JSON)
    return true;

if (languageType == LangType::L_JSON5)
{
    auto fileName = GetCurrentFileName();
    StringHelper::ToLower(fileName);
    return fileName.ends_with(L".jsonc");
}

return false;

A genuine .json5 document (unquoted keys, single-quoted strings) does not match the extension check and keeps being ignored by the plugin exactly as it was before - no parsing, no error dialog, no change in behaviour.

Verification

Measured end to end in a real Notepad++ (8.9.6.2, default langs.xml):

  • .jsonc and .json5 are both reported as the same language type (86 = L_JSON5), so the extension check is what actually separates them;
  • with draw-on-open enabled, the .jsonc document is drawn automatically while the byte-identical content named .json5 is not;
  • the rest of the jsonc assertions (snapshot caching, opt-in behaviour, manual refresh) pass unchanged.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@leoshone
Recognize .jsonc without implying JSON5 support
3b9d8c6
IsJsonFile() used to accept every L_JSON5 document. Notepad++ maps the
.jsonc extension to the json5 language ("json5 jsonc" share one entry in
the default langs.xml), but that also pulled in genuine .json5 documents,
whose syntax (unquoted keys, single-quoted strings) the parser does not
support: they used to be silently ignored by the plugin and would now be
parsed and reported as an error.

Accept the json5 language for .jsonc files only, so a real .json5 file
keeps behaving exactly as before this change.

Verified end to end: .jsonc and .json5 are both reported as the same
language (86) by Notepad++, the .jsonc document is drawn while the .json5
one is not, and the existing jsonc assertions still pass.
@leoshone leoshone mentioned this pull request Sep 7, 2026
Persist the tree view zoom level across Notepad++ sessions #251
Merged
leoshone added a commit to leoshone/JSON-Viewer that referenced this pull request Sep 7, 2026
@leoshone
Record the upstream round of 09-07: NPP-JSONViewer#251 merged, rebase, …
41a2206
…NPP-JSONViewer#255 opened

- NPP-JSONViewer#251 was approved and merged - the small-pure-PR strategy works.
- Upstream moved to fa8d2b9 (settings saved on exit via writeIfChanged,
  include reordering) and renamed our TREE_ZOOM key to TREE_ZOOM_LEVEL;
  documented the consequences for the next integration sync.
- NPP-JSONViewer#253/NPP-JSONViewer#254 rebased onto fa8d2b9, all three PRs mergeable again.
- NPP-JSONViewer#255 opened for the narrow jsonc recognition, with the forward pointer
  added to the NPP-JSONViewer#251 thread as planned.
@SinghRajenM
SinghRajenM merged commit 36bcd33 into NPP-JSONViewer:master Oct 18, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@leoshone @SinghRajenM
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.