šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

json-logic-js

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-logic-js

Build complex rules, serialize them as JSON, and execute them in JavaScript

2.0.5
latest
Source
npm
Version published
Weekly downloads
316K
5.34%
Maintainers
1
Weekly downloads
Ā 
Created

What is json-logic-js?

The json-logic-js package allows you to apply logical operations and rules to JSON data. It is useful for creating complex conditional logic in a declarative way, making it easier to manage and understand.

What are json-logic-js's main functionalities?

Basic Logic Operations

This feature allows you to perform basic logical operations such as 'if', 'and', 'or', and comparison operators. The code sample checks if 3 is greater than 1 and returns 'yes' if true, otherwise 'no'.

{"if": [{">": [3, 1]}, "yes", "no"]}

Data Manipulation

This feature allows you to manipulate data using operations like 'map', 'reduce', and 'filter'. The code sample increments each element in the array [1, 2, 3] by 1.

{"map": [[1, 2, 3], {"+": [1, {"var": ""}]}]}

Variable Handling

This feature allows you to handle variables within your JSON logic. The code sample retrieves the value of 'user.name' from the data context.

{"var": "user.name"}

Custom Operations

This feature allows you to define custom operations. The code sample demonstrates a custom 'log' operation that logs the value of 'message'.

{"log": [{"var": "message"}]}

Other packages similar to json-logic-js

Keywords

json

FAQs

Package last updated on 09 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts