Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 1.03 KB

README.md

File metadata and controls

61 lines (43 loc) · 1.03 KB

json-logic-parser

Parses infix mathematical expressions and outputs an json rule object

Description

json-logic-parser is a lightweight mathematical parser that creates JsonLogic rule objects out of mathematical expressions in infix notation

Based on Mauricio Poppe's mr-parser

Usage

var Parser = require('json-logic-parser').Parser;
Parser.parse('1 - (2 + 3) * 4')

// returns
[
  {
    "-": [
      "1",
      {
        "*": [
          {
            "+": [
              "2",
              "3"
            ]
          },
          "4"
        ]
      }
    ]
  }
]

API

Parser = require('json-logic-parser').Parser

Parser.parse(expression)

params

  • expression {string} the expression to be parsed

returns

  • Returns a JsonLogic rule object.

2018 MIT © Rauno Kulla