@lanetix/odata-parser v9.0.0
OData query string parser for node.js based on pegjs.
Installation
npm install odata-parser
Usage: parse()
var parser = require("odata-parser");
var ast = parser.parse("$top=10&$skip=5&$select=foo")
util.inspect(ast)
will result in:
{
'$top': 10,
'$skip': 5,
'$select': [ 'foo' ]
}
Filters like:
parser.parse("$filter=Name eq 'John' and LastName lt 'Doe'")
results in:
{
$filter: {
type: 'and',
left: {
type: 'eq',
left: {
type: 'property',
name: 'Name'
},
right: {
type: 'literal',
value: 'John'
}
},
right: {
type: 'lt',
left: {
type: 'property',
name: 'LastName'
},
right: {
type: 'literal',
value: 'Doe'
}
}
}
}
Using functions in filters
parser.parse("$filter=substringof('nginx', Servers)")
results in:
{
$filter: {
type: 'functioncall',
func: 'substringof',
args: [{
type: 'literal',
value: 'nginx'
}, {
type: 'property',
name: 'Servers'
}]
}
}
Usage: stringify()
var mod = require("odata-parser");
var uri = `$filter=( nullable_string ne null and telephone_number eq 999999999 )&$select=name`
var originalAst = mod.parse(uri)
var remadeOdata = mod.stringify(originalAst)
var reParsedAst = mod.parse(remadeOdata)
console.log(remadeOdata)
will result in:
`$select=name&$filter=((nullable_string) ne (null)) and ((telephone_number) eq (999999999))`
assert passes as well:
assert.deepEqual(originalAst, reParsedAst)
Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Author
License
This project is licensed under the MIT license. See the LICENSE file for more info.
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago