question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[json] schema Validation/Intellisense very slow when JSON deep and Schema Complex

See original GitHub issue

In my project we design an API that allows people to define web pages in json using a bunch of nested components. We have schema files for all components and how to combine them. When merged into 1 schema file it becomes around 7000 lines long.

I am noticing a huge slowdown when a file has JSON that is relatively deep.

Here is what it looks like when the depth is still okay fast

And here is what it looks like when a deep component is defined in the same file slow

  • VSCode Version: Version 1.20.0-insider
  • OS Version: OSX 10.13.3

Steps to Reproduce:

  1. Set schema for JSON to some large and complex schema
  2. Open up a JSON file that uses the schema
  3. write enough JSON so that you are nested a bunch
  4. try to use intellisense
  • whole editor slows down
  • Intellisense suggestion doesn’t pop up until validation is done - even looks like it validates the file a few ways while you sit

Is it possible to just turn off JSON validation and keep the Intellisense? Or just validate on file save? Could we show Intellisense suggestions before validation happens?

Also, when i am editing 2 JSON files the slowness is shared by the two. Even after closing the file that made everything slow, I still have to wait for some validation thing to finish before it realized the file is closed and updates the UI

If needed I can try to reproduce this bug with generic schema files.

What seems to be the issue is when i have a Collection component. This component can hold any other component, including more nested collections. If I nest a bunch of collections the problem presents itself.

Does this issue occur when all extensions are disabled?: Yes/No Yes

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
aeschlicommented, Sep 27, 2018

Thanks a lot for the example, and sorry for the wait. It’s an interesting example, and the our schema validation gets to its limits.

Each node can have have multiple alternatives. When testing which alternative to use we test the full object, including children and children’s children. Each child type again has many alternatives.

To make this more performant we need to avoid validating children if we see that we are of the wrong type.

0reactions
hipstersmoothiecommented, Feb 23, 2018

I have also provided a test file which shows the slowness

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intellisense for JSON Schema in the JSON Editor - .NET Blog
This will make working with complex JSON structures based on a schema much easier. Specify the schema within a JSON file using the...
Read more >
json.net Schema IsValid slow - Stack Overflow
Lets say i run a simple "Hello @Model.Name!" template that validates that json has string Name this is 15-20 times slower then if...
Read more >
VS Code tips — JSON schemas for IntelliSense - YouTube
Set the "$scheme" property in any json file to apply a schema to it. Schemas validate your json and provide IntelliSense while writing...
Read more >
Strategy for improving validation performance? - Google Groups
I've generated a rather large and somewhat complex schema. ... FWIW the source 'schema' that I'm using for building the JSON Schema is...
Read more >
Use code completion for your custom JSON format in just 1 ...
With “$ref” we can reference others JSON schema in order to build complex types using schema recursivity. How a JSON schema is referenced?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found