Skip to content

parses infix mathematical expressions and outputs an json logic rule object that represents the expression

Notifications You must be signed in to change notification settings

raunokulla/json-logic-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

parses infix mathematical expressions and outputs an json logic rule object that represents the expression

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%