UNPKG

jsonata-extended

Version:
150 lines (103 loc) 6.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Home - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc.css"> <script src="scripts/nav.js" defer></script> <script src="https://embed.runkit.com"></script> <style>.embedrunkit { overflow: visible; }</style> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav > <input type="text" id="nav-search" placeholder="Search" /> <h2><a href="index.html">Home</a></h2><h2><a href="https://github.com/martinholden-skillsoft/jsonata-extended.git" target="_blank" class="menu-item" id="repository" >Github repo</a></h2><h3>Modules</h3><ul><li><a href="module-jsonata-functions.html">jsonata-functions</a><ul class='methods'><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~decodeUuid">decodeUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~encodeUuid">encodeUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~htmltotext">htmltotext</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~languageInfo">languageInfo</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~moment">moment</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~momentDuration">momentDuration</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~mustache">mustache</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~parsePath">parsePath</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~parseUrl">parseUrl</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~registerWithJSONATA">registerWithJSONATA</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~shortenUuid">shortenUuid</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~truncate">truncate</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~unicodeToASCII">unicodeToASCII</a></li><li data-type='method' style='display: none;'><a href="module-jsonata-functions.html#~unshortenUuid">unshortenUuid</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#jsonataExtended">jsonataExtended</a></li></ul> </nav> <div id="main"> <section class="package"> <h3> </h3> </section> <section class="readme usertext"> <article><h1>jsonata-extended</h1> <p><a href="https://github.com/martinholden-skillsoft/jsonata-extended/actions/workflows/ci.yml"><img src="https://github.com/martinholden-skillsoft/jsonata-extended/actions/workflows/ci.yml/badge.svg" alt="JSONata Extended CI"></a></p> <p>Extended JSONata object with custom functions</p> <p>This can be used to add extended functions to the standard <a href="https://www.npmjs.com/package/jsonata">JSONata</a></p> <p>It has the same signature as the standard and so can be used as a dropin replacement.</p> <h2>Installation</h2> <pre class="prettyprint source lang-bash"><code>npm install jsonata-extended </code></pre> <h2>Example - Node</h2> <pre class="prettyprint source lang-javascript"><code>// const jsonata = require('jsonata'); const jsonata = require('jsonata-extended'); const expr = jsonata( '$htmltotext(&quot;&lt;p>Leadership has a dark side; a &#34;leadership shadow&#34; that often creates an unknown; lurking fear.&lt;/p>&quot;)' ); const result = expr.evaluate(); </code></pre> <h2>Example - Browser</h2> <pre class="prettyprint source lang-html"><code>&lt;!DOCTYPE html> &lt;html lang=&quot;en&quot;> &lt;head> &lt;meta charset=&quot;UTF-8&quot;> &lt;title>JSONata Extended Test&lt;/title> &lt;script src=&quot;https://cdn.jsdelivr.net/npm/jsonata/jsonata.min.js&quot;>&lt;/script> &lt;script src=&quot;node_modules/jsonata-extended/dist/jsonata-extended.min.js&quot;>&lt;/script> &lt;script> function runTransform() { var json = JSON.parse(document.getElementById('json').value); var transform = document.getElementById('transform').value; var resultJSONataExtended = jsonataExtended(transform).evaluate(json); document.getElementById('results').innerHTML = JSON.stringify(resultJSONataExtended); } &lt;/script> &lt;/head> &lt;body> &lt;textarea id=&quot;json&quot;>{ &quot;name&quot;: &quot;Wilbur&quot;, &quot;uuid&quot;: &quot;11bf5b37-e0b8-42e0-8dcf-dc8c4aefc000&quot; }&lt;/textarea> &lt;textarea id=&quot;transform&quot;>$.{ &quot;responsename&quot;: name, &quot;responseuuid&quot;: uuid, &quot;responseshortenUuid&quot; : $shortenUuid ? $shortenUuid(uuid) : &quot;function not defined&quot;}&lt;/textarea> &lt;button onclick=&quot;runTransform()&quot;>Click me&lt;/button> &lt;p id=&quot;results&quot;>&lt;/p> &lt;/body> &lt;/html> </code></pre> <h2>JSDOCS</h2> <p><a href="https://martinholden-skillsoft.github.io/jsonata-extended/doc/">JavaScript Documentation</a></p> <h2>License</h2> <p>MIT © Martin Holden</p></article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme. </footer> <script>prettyPrint();</script> <script src="scripts/polyfill.js"></script> <script src="scripts/linenumber.js"></script> <script src="scripts/search.js" defer></script> <script src="scripts/collapse.js" defer></script> <script> const elements = [...document.getElementsByClassName('embedrunkit')] const notebooks = elements.reduce((notebooks, element) => { const innerText = element.firstChild const currentCell = window.RunKit.createNotebook({ element, nodeVersion:"12.x.x", source: innerText.textContent, // Remove the text content of the pre tag after the embed has loaded onLoad: () => innerText.remove() }) return notebooks }, [])</script> </body> </html>