json-logic-js is a JavaScript parser and executor for JsonLogic rules, allowing developers to define complex business logic as JSON objects. This enables the sharing and persistence of rules across different programming languages (e.g., JavaScript and PHP) and environments (front-end, back-end, database storage). The library currently stands at version 2.0.5, with an infrequent release cadence focused on maintenance and bug fixes rather than rapid feature development. Its core differentiator is the adherence to the well-documented, language-agnostic JsonLogic format, which explicitly separates rules from data and avoids side effects, ensuring deterministic computation. Alternatives like `json-logic-engine` offer modern ESM/CJS support and performance optimizations, highlighting `json-logic-js`'s legacy UMD module format as a point of contrast.
npm install json-logic-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates defining and applying a compound JSON Logic rule with dynamic data, showcasing comparison and nested object access.
Migrate package management from Bower to npm or Yarn using `npm install json-logic-js` or `yarn add json-logic-js`.
Include polyfills for `Array.map` and `Array.reduce` (e.g., via Babel or directly from MDN) if supporting legacy browsers.
Ensure your project's build tooling (e.g., Webpack, Rollup) or Node.js environment is configured to correctly handle UMD packages. Consider using `createRequire` in some ESM contexts for CJS-like imports if issues arise, or evaluate modern alternatives that offer explicit ESM/CJS dual builds for better interoperability.
Ensure you are importing `jsonLogic` as a default export in ESM (`import jsonLogic from 'json-logic-js';`) or correctly assigning the `require()` result in CommonJS (`const jsonLogic = require('json-logic-js');`).Add `import jsonLogic from 'json-logic-js';` (ESM) or `const jsonLogic = require('json-logic-js');` (CommonJS) at the top of your file to make the `jsonLogic` object available.Review the JsonLogic rule definition against the official documentation at jsonlogic.com/operations.html and ensure it matches the `RulesLogic` interface from `@types/json-logic-js`. Pay attention to operator positions (key) and operand types (array or single value).
No dependency data recorded yet.