Skip to content

Handle Large Arrays with the JSON editor

Engelbert Niehaus edited this page Jun 24, 2017 · 14 revisions

Large Array

Depending on the size your JSON file you want to edit with the JSON Editor large arrays can easily drive the Javascript engine of you browser towards a timeout. In a testing environment 900 records with meta information about the marker on map in OpenLayers map exceeded the capacity of the JSON editor.

The solution is a wrapper for the JSON editor. Jeremy Dorns JSON editor is used for single records (a hash/object) of a single geolocation marker and the wrapper lets you navigate and select the JSON the record.

Create a Wrapper Class

First you will create a wrapper class for large array with the following methods

var vLAE = new LargeArrayEditor()

The LargeArrayEditor is a JavaScript-Class with the following attributes and methods this.la = ... // Attribute: array of record this.current = 0; // Attribute: is the current index of the

this.first() // Method: set current=0 this.last() // Method: set current=this.la.length-1 this.next() // Method: this.current++ if this.current < this.la.length-1 this.prev() // Method: this.current-- if this.current > 0 this.edit() // Method: call the JSON Editor for current record in editor

Use font-awesome icons for calling the methods of the LargeArrayEditor. By calling the JSON editor just a single record (hash/object) the capacity problem in a browser to handle large arrays was solved.

Clone this wiki locally