
* jupyter:active */ĭefiant.registerTemplate(template_string) When the "tree-walker" template calls itself, indentation is passed as an argument, thus indenting child elements of a folder. It contains recursive template calling and renders a fictitious filesystem structure. Check out the examples below to get a hint of how it can be used the first one is rather simple and the latter is more advanced and demonstrates calling templates from another template. Besides the fact that XSLT is a proven Turing-complete language, it is also standardized and supported by all major browsers. With Defiant, you can write logical templates with powerful technologies such as XSLT & XPath, and apply them to JSON objects. Problems arise when complex real-world requirements exceed the limits of the templating model, so you have to supplement the templates with helper functions, fragmenting the templating logic, which is bad practice. this is many times faster than 'regular search'įound = arch(snapshot, '//book') Ĭontemporary JavaScript templating libraries enable you to write simplistic templates. Var data = await fetchJSON( '/res/json/store.json') Var defiant = await fetchScript( '/res/js/modules/defiant.js') This approach brings a smoother experience and applies especially when dealing with large data - larger than 1 MB of JSON data.

Consequently in version v1.2.6 a snapshot can be created utilizing web workers. Though it turned out that this preparation have a blocking effect on the UI-thread. With really large JSON structures, avoiding to do the time-consuming preparation on each search has proven to be beneficial. Using snapshot of the JSON structure, Defiant can find and return matches as fast as 4ms on 1.6MB large data Defiant prepares the JSON structure before the search this preparation is the time-consuming part.

facets will now contain grouped values from facet-search // the values of 'eyeColors' is listed as tableĭefiant v1.2.0 introduced a snapshot feature that improves search performance more than 100 times compared to a regular search. import 'defiant' var defiant = await fetchScript( '/res/js/modules/defiant.js') Try out the XPath Evaluator to get the idea. Defiant extends the global JSON object with a "search" method that enables lightning-fast searches using XPath expressions. Do you need to query large JSON structures? Do you end up coding loops to parse the JSON and identify the data that matches your query? Defiant offers a better way.
