Skip to content

Repository files navigation

rqb-parser

JavaScript parser for parsing RQB (react-querybuilder) JSON into expr (expr-lang) expressions

Usage

RQBParser.parse(rqbJson)

Example

Input:

{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"value": "4,55",
"operator": "between"
},
{
"field": "age",
"operator": ">",
"value": "5"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField2",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "notBetween",
"value": "1954-10-03,1960-06-06"
},
{
"field": "job",
"operator": "=",
"valueSource": "value",
"value": "developer"
},
{
"rules": [
{
"field": "instrument",
"operator": "=",
"valueSource": "value",
"value": "Cowbell"
},
{
"field": "alsoPlays",
"operator": "in",
"valueSource": "value",
"value": "Cowbell,More cowbell,Spoon,Wooden fish,Ocarina"
}
],
"combinator": "or",
"not": false
}
]
}

Result:

firstName startsWith "Stev"
and (lastName in ["Vai"," Vaughan"])
and (age >= 4 and age <= 55)
and age > 5
and (isMusician == true or instrument == "Guitar")
and groupedField1 == groupedField2
and (birthdate <"1954-10-03" and birthdate >"1960-06-06")
and job == "developer"
and (instrument == "Cowbell" or (alsoPlays in ["Cowbell","More cowbell","Spoon","Wooden fish","Ocarina"]))

About

parse react query builder JSON into expr lang expressions

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages