Socket
Book a DemoInstallSign in
Socket

json-logic

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-logic

Package for expressing logical operations in JSON. Useful for storing logical procedures in a database.

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
97
-3%
Maintainers
1
Weekly downloads
 
Created
Source

node-json-logic

Package for expressing logical operations in JSON. Useful for storing logical procedures in a database.

Examples of use

var JSONMath = require('json-logic');
var logic = new JSONLogic();
var result = logic .execute({
	"a": {
		"operation": "||",
		"variables": [
			{
				"operation": "<",
				"variables": [
					5,
					1
				]
			},
			{
				"operation": "&&",
				"variables": [
					{
						"operation": "==",
						"variables": [
							8,
							2
						]
					},
					true
				]
			}
		]
	}
});

After this has executed, the value of a will be false.

You can also pass in an array of operations to perform, and even reference variables inside the procedure

[
	{
		"a": true,
		"b": false
	},
	{
		"c": {
			"operation": "&&",
			"variables": [
				"a",
				"b"
			]
		}
	},
	{
		"c": "c"
	}
]

After this the value of a will be true, b will be false and c will be false.

Keywords

logic

FAQs

Package last updated on 16 Apr 2015

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.