josdejong / jsoneditor

A web-based tool to view, edit, format, and validate JSON
http://jsoneditoronline.org
Apache License 2.0
11.59k stars 2.04k forks source link

Tree search very slow. Additional options for tree searchbox needed. #366

Open SuperMario77 opened 7 years ago

SuperMario77 commented 7 years ago

Hi,

I use the JSONEditor to display a very big JSON file (1MB=30000 lines, is this really big?). The tree and all other modes are working perfect and fast. But when I use the search box in the tree mode and enter 1 character, e.g. "u", the complete browser is completly hanging because of searching for this "u". I have a lot of nodes with keyname "uuid". I think this could be the problem here? Or has the tree search a known performance problem?

It would be nice if I can set some options for the search field when creating the JSONEditor instance. For example, that the realtime search should only start if the user enters at least 3 characters. Or a possibility to disable the realtime search and only search if user press the"Enter" key.

I found in the source dist/jsoneditor.js (v5.5.11) in line 11379 the following code:

SearchBox.prototype._onSearch = function (forceSearch) {
      this._clearDelay();

      var value = this.dom.search.value;
      var text = (value.length > 0) ? value : undefined;

If this "0" would be parameterized, then I could set it to "2" and the search starts only when user enters at least 3 characters. But this solves not the tree search performance, or?!

Regards, Mario

UPDATE: It could be that not the search is the problem, but the expanding of each node where the "u" is found. Because the "u" is found 2000 times. Actually not so much, but it seems the browser is hanging during drawing the big tree with all nodes open where the "u" was found.

josdejong commented 7 years ago

It could be that not the search is the problem, but the expanding of each node where the "u" is found.

indeed, rendering is typically the bottleneck. In the first next breaking release (~v6~ next) this behavior will change: not all search results will expand, but upon setting focus to a (next) search result it will expand if needed.