
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@lanetix/odata-parser
Advanced tools
OData query string parser for node.js based on pegjs.
npm install odata-parser
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'
        }]
    }
}
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)
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.
This project is licensed under the MIT license. See the LICENSE file for more info.
FAQs
OData query string parser
We found that @lanetix/odata-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 27 open source maintainers collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.